summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index e5764f0..1df308f 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -260,6 +260,28 @@ public abstract class Map extends Board
clearPointVector(possibleTargets);
}
+ public boolean attackPawn(Pawn pawn, GridPoint2 from, GridPoint2 to, int dice)
+ {
+ Hex hex = getHex(to.x, to.y);
+ Pawn target = hex.getTopPawn();
+
+ int activatedUnits = activatedPawns.size();
+
+ if (dice == 2) return false;
+ if (dice == 12) return true;
+
+ // TODO : flank attack
+ boolean success = (dice + activatedUnits >= hex.defenseFor(target, activatedPawns));
+
+ // TODO : free move for infantry
+ for (Pawn p : activatedPawns)
+ pawn.attack(target);
+ activablePawns.clear();
+ activatedPawns.clear();
+
+ return success;
+ }
+
public int movePawn(Pawn pawn, GridPoint2 from, Orientation o)
{
System.err.println(" movePawn : " + from.x + ";" + from.y + " " + o);