summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-13 12:18:03 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-13 12:18:03 +0200
commit5a51e0a605d9f33ee21027a206b709216c68d3fb (patch)
tree57740545f9e360b5fb31e126d8cbf38ad036613c
parenta9b860b98a33c796faafb0e300418e0e5dadff1f (diff)
downloadRustAndDust-5a51e0a605d9f33ee21027a206b709216c68d3fb.zip
RustAndDust-5a51e0a605d9f33ee21027a206b709216c68d3fb.tar.gz
Map: boolean attackPawn(Pawn, GridPoint2, GridPoint2, int)
-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);