diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-17 16:56:39 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-17 16:56:39 +0100 |
commit | 5f5e780e47a6dd041e741b24f9818ee5b9c0d2a9 (patch) | |
tree | 527f3942d392b7e19f7c1b50d998975e4274798a /core/src/ch/asynk/tankontank | |
parent | a66960a1513248f7b7900663c9e0fe4b38b08baf (diff) | |
download | RustAndDust-5f5e780e47a6dd041e741b24f9818ee5b9c0d2a9.zip RustAndDust-5f5e780e47a6dd041e741b24f9818ee5b9c0d2a9.tar.gz |
Map: use new engagement resolution API
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index f405845..970e750 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -261,15 +261,24 @@ public abstract class Map extends Board pawn.engagement.calculus = "2D6 -> (6 + 6) automatic success"; return true; } else { - int flankAttacks = 0; + + boolean flankAttack = false; + boolean terrainBonus = true; + for (Pawn assist : activatedPawns) { if (assist.isFlankAttack()) - flankAttacks = 1; + flankAttack = true; + if (assist.isA(Unit.UnitType.INFANTRY)) + terrainBonus = false; } - int activatedUnits = activatedPawns.size(); - int def = target.getTile().defenseFor(pawn, target, activatedPawns); - pawn.engagement.calculus = "2D6 -> (" + d1 + " + " + d2 + ") + " + activatedUnits + " + " + flankAttacks; - return ((dice + activatedUnits + flankAttacks) >= def); + + int cnt = activatedPawns.size(); + int def = target.getDefense(pawn.getTile()); + int flk = (flankAttack ? Unit.FLANK_ATTACK_BONUS : 0); + int tdf = (terrainBonus ? pawn.getTile().defense() : 0); + + pawn.engagement.calculus = "2D6(" + d1 + " + " + d2 + ") + " + cnt + " + " + flk + " >= " + def + " + " +tdf; + return ((dice + cnt + flk) >= (def + tdf)); } } |