diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 1 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Tile.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 11 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/states/StateAttack.java | 2 |
5 files changed, 13 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 9bab3be..bc498e2 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -31,6 +31,7 @@ public abstract class Pawn implements Moveable, Disposable Pawn target; boolean isClear; boolean isFlank; + public String calculus; } private static final float MOVE_TIME = 0.4f; diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java index 5ba6e1b..539725b 100644 --- a/core/src/ch/asynk/tankontank/engine/Tile.java +++ b/core/src/ch/asynk/tankontank/engine/Tile.java @@ -24,7 +24,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn> private StackedImages overlays; private ArrayDeque<Pawn> stack; - public abstract int defenseFor(Pawn target, Board.PawnCollection foes); + public abstract int defenseFor(Pawn pawn, Pawn target, Board.PawnCollection foes); public abstract int costFrom(Pawn pawn, Orientation side, boolean road); public abstract boolean isOffMap(); diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java index 45d3d43..4a1e2f5 100644 --- a/core/src/ch/asynk/tankontank/game/Hex.java +++ b/core/src/ch/asynk/tankontank/game/Hex.java @@ -110,7 +110,7 @@ public class Hex extends Tile } @Override - public int defenseFor(Pawn target, Board.PawnCollection foes) + public int defenseFor(Pawn pawn, Pawn target, Board.PawnCollection foes) { Unit u = (Unit) target; boolean terrainBonus = true; @@ -139,7 +139,7 @@ public class Hex extends Tile break; } - System.err.println(" >= " + def + " + " + tdef); + pawn.attack.calculus += " >= " + def + " + " + tdef; return (def + tdef); } } diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index db0f6b6..06d0b8a 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -232,14 +232,17 @@ public abstract class Map extends Board ctrl.animationDone(); } - public boolean attackPawn(Pawn pawn, final Pawn target, int dice) + public boolean attackPawn(Pawn pawn, final Pawn target, int d1, int d2) { int activatedUnits = activatedPawns.size(); + int dice = d1 + d2; final boolean success; if (dice == 2) { + pawn.attack.calculus = "2D6 -> (1 + 1) automatic failure"; success = false; } else if (dice == 12) { + pawn.attack.calculus = "2D6 -> (6 + 6) automatic success"; success = true; } else { int flankAttacks = 0; @@ -249,9 +252,11 @@ public abstract class Map extends Board break; } } - System.err.print(" + " + activatedUnits + " + " + flankAttacks); - success = ((dice + activatedUnits + flankAttacks) >= target.getTile().defenseFor(target, activatedPawns)); + pawn.attack.calculus = "2D6 -> (" + d1 + " + " + d2 + ") + " + activatedUnits + " + " + flankAttacks; + int def = target.getTile().defenseFor(pawn, target, activatedPawns); + success = ((dice + activatedUnits + flankAttacks) >= def); } + System.err.println(pawn + " attacks " + target + " : " + pawn.attack.calculus); AnimationSequence seq = AnimationSequence.get(2); if (success) { diff --git a/core/src/ch/asynk/tankontank/game/states/StateAttack.java b/core/src/ch/asynk/tankontank/game/states/StateAttack.java index 8b1e068..397b8a6 100644 --- a/core/src/ch/asynk/tankontank/game/states/StateAttack.java +++ b/core/src/ch/asynk/tankontank/game/states/StateAttack.java @@ -81,7 +81,7 @@ public class StateAttack extends StateCommon int d1 = ctrl.player.d6(); int d2 = ctrl.player.d6(); System.err.print(" attack (" + selectedHex.getCol() + ";" + selectedHex.getRow() + ") -> (" + to.getCol() + ";" + to.getRow() + ") : 2D6 -> (" + d1 + " + " + d2 + ")"); - if (map.attackPawn(selectedUnit, activeUnit, d1 + d2)) { + if (map.attackPawn(selectedUnit, activeUnit, d1, d2)) { ctrl.opponent.casualty(activeUnit); if (map.breakPawns.size() > 0) setNextState(StateType.BREAK); |