From 5f5e780e47a6dd041e741b24f9818ee5b9c0d2a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 17 Nov 2014 16:56:39 +0100 Subject: Map: use new engagement resolution API --- core/src/ch/asynk/tankontank/game/Map.java | 21 +++++++++++++++------ 1 file 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)); } } -- cgit v1.1-2-g2b99