diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-13 17:14:30 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-13 17:14:30 +0200 |
commit | eb01d000218cc87f71937aec0e01d3d360125fd7 (patch) | |
tree | 73fc131e19bc71a57dc78175912f48b4bb87a5d6 /core/src/ch/asynk/tankontank/game | |
parent | a0b2ae4c0e05a4d13169d0ea6d688ace34e4c155 (diff) | |
download | RustAndDust-eb01d000218cc87f71937aec0e01d3d360125fd7.zip RustAndDust-eb01d000218cc87f71937aec0e01d3d360125fd7.tar.gz |
Map: support flank attack
Diffstat (limited to 'core/src/ch/asynk/tankontank/game')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 2 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 14 |
2 files changed, 11 insertions, 5 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java index ef5b641..b586515 100644 --- a/core/src/ch/asynk/tankontank/game/Hex.java +++ b/core/src/ch/asynk/tankontank/game/Hex.java @@ -131,7 +131,7 @@ public class Hex extends Tile break; } - System.err.println(" def:" + def); + System.err.println(" >= " + def); return def; } } diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index 2519ab0..6f20db8 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -257,10 +257,9 @@ public abstract class Map extends Board clearPointVector(possibleTargets); } - public boolean attackPawn(Pawn pawn, GridPoint2 from, GridPoint2 to, int dice) + public boolean attackPawn(Pawn pawn, Pawn target, GridPoint2 from, GridPoint2 to, int dice) { Hex hex = getHex(to.x, to.y); - Pawn target = hex.getTopPawn(); int activatedUnits = activatedPawns.size(); @@ -270,8 +269,15 @@ public abstract class Map extends Board } else if (dice == 12) { success = true; } else { - // TODO : flank attack - success = (dice + activatedUnits >= hex.defenseFor(target, activatedPawns)); + int flankAttacks = 0; + for (Pawn assist : activatedPawns) { + if (assist.isFlankAttack()) { + flankAttacks = 1; + break; + } + } + System.err.print(" + " + activatedUnits + " + " + flankAttacks); + success = ((dice + activatedUnits + flankAttacks) >= hex.defenseFor(target, activatedPawns)); } // TODO : free move for infantry |