diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-01 12:47:08 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-01 12:47:08 +0100 |
commit | 3943d25a24ec6c444271b174e8655824a0ecca8a (patch) | |
tree | 7476a0053348a8baa59c63503b2e1f40fd8788ac /core/src/ch/asynk/tankontank/game | |
parent | d3f71a20ccf6c8ce83f51e8638e1dca7a13d685f (diff) | |
download | RustAndDust-3943d25a24ec6c444271b174e8655824a0ecca8a.zip RustAndDust-3943d25a24ec6c444271b174e8655824a0ecca8a.tar.gz |
Pawn: add attack.calculus String and feed it
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-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 |
3 files changed, 11 insertions, 6 deletions
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); |