summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/Hud.java13
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java31
-rw-r--r--core/src/ch/asynk/tankontank/game/states/StateEngage.java2
4 files changed, 30 insertions, 19 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java
index 70fc641..11329b6 100644
--- a/core/src/ch/asynk/tankontank/engine/Pawn.java
+++ b/core/src/ch/asynk/tankontank/engine/Pawn.java
@@ -35,11 +35,10 @@ public abstract class Pawn implements Moveable, Disposable
int distance;
boolean isClear;
boolean isFlank;
- public String calculus;
public String toString()
{
- return "engage : " + target + " distance:" + distance + " clear:" + isClear + " flank:" + isFlank + " " + calculus;
+ return "engage : " + target + " distance:" + distance + " clear:" + isClear + " flank:" + isFlank;
}
public void reset()
diff --git a/core/src/ch/asynk/tankontank/game/Hud.java b/core/src/ch/asynk/tankontank/game/Hud.java
index 49b8a34..dd88f04 100644
--- a/core/src/ch/asynk/tankontank/game/Hud.java
+++ b/core/src/ch/asynk/tankontank/game/Hud.java
@@ -42,7 +42,8 @@ public class Hud implements Disposable
ABORT_TURN,
END_TURN,
END_DEPLOYMENT,
- END_GAME
+ END_GAME,
+ NONE
}
public Hud(final Ctrl ctrl, final TankOnTank game)
@@ -187,6 +188,9 @@ public class Hud implements Disposable
stats.visible = false;
ctrl.endGame();
break;
+ case NONE:
+ default:
+ break;
}
okCancel.visible = false;
ctrl.blockMap = false;
@@ -220,6 +224,13 @@ public class Hud implements Disposable
okCancel.show("Deployment unit count reached.\nEnd Deployment phase ?", Position.MIDDLE_CENTER);
}
+ public void engagementSummary(String msg)
+ {
+ ctrl.blockMap = true;
+ dialogAction = DialogAction.NONE;
+ okCancel.show(msg, Position.BOTTOM_CENTER, false);
+ }
+
public void victory(Player winner, Player loser)
{
ctrl.blockMap = true;
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 94ba334..bd36a7f 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -269,14 +269,16 @@ public abstract class Map extends Board
{
int d1 = d6();
int d2 = d6();
- int dice = d1 + d2;
-
- if (dice == 2) {
- unit.engagement.calculus = "2D6 -> (1 + 1) automatic failure";
- return false;
- } else if (dice == 12) {
- unit.engagement.calculus = "2D6 -> (6 + 6) automatic success";
- return true;
+ int die = d1 + d2;
+
+ String msg;
+ boolean success = false;
+ if (die == 2) {
+ msg = "Die : 1 + 1 => Automatic failure";
+ success = false;
+ } else if (die == 12) {
+ msg = "Die : 6 + 6 => Automatic success";
+ success = true;
} else {
int distance = 0;
@@ -309,12 +311,15 @@ public abstract class Map extends Board
else if (distance > 1)
wdf = 1;
}
+ int s1 = (die + cnt + flk);
+ int s2 = (def + tdf + wdf);
+ success = (s1 >= s2);
- unit.engagement.calculus = "2D6(" + d1 + " + " + d2 + ") + " + cnt + " + " + flk + " >= " + def + " + " + tdf + " + " + wdf;
- if (night)
- unit.engagement.calculus += " + " + wdf;
- return ((dice + cnt + flk) >= (def + tdf + wdf));
+ msg = String.format("die : %d + %d\nunits : +%d\nflank: +%d\n = %d\ndefense: %d\nterrain: +%d\nweather: +%d\n = %d\n%s",
+ d1, d2, cnt, flk, s1, def, tdf, wdf, s2, (success ? "target destroyed" : "target missed"));
}
+ ctrl.hud.engagementSummary(msg);
+ return success;
}
private void setFightAnimation(final Unit target, boolean success)
@@ -353,8 +358,6 @@ public abstract class Map extends Board
success = resolveFight(unit, target);
}
- TankOnTank.debug(unit + " engagements " + target + " : " + unit.engagement.calculus + " " + success);
-
breakUnits.clear();
for (Unit u : activatedUnits) {
u.engage();
diff --git a/core/src/ch/asynk/tankontank/game/states/StateEngage.java b/core/src/ch/asynk/tankontank/game/states/StateEngage.java
index f20bb9f..778ab03 100644
--- a/core/src/ch/asynk/tankontank/game/states/StateEngage.java
+++ b/core/src/ch/asynk/tankontank/game/states/StateEngage.java
@@ -56,14 +56,12 @@ public class StateEngage extends StateCommon
StateType nextState = StateType.DONE;
if (map.engageUnit(selectedUnit, activeUnit)) {
ctrl.player.wonEngagementCount += 1;
- ctrl.hud.notify(selectedUnit.engagement.calculus + " : " + activeUnit + " is destroyed");
ctrl.opponent.casualty(activeUnit);
if (map.breakUnits.size() > 0) {
nextState = StateType.BREAK;
}
} else {
ctrl.player.lostEngagementCount += 1;
- ctrl.hud.notify(selectedUnit.engagement.calculus + " : failure");
}
activeUnit.showTarget();