summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-29 09:30:32 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-29 09:30:32 +0100
commit47fa20f6ae602fcd3abfe571b11c0c96c49896cf (patch)
treeac0d75dc64dc4c9eb773eb7481ec2e666a6df8b8 /core/src/ch/asynk
parenta80da9a482b91001dc6b0ebf50ef8bdd455f105e (diff)
downloadRustAndDust-47fa20f6ae602fcd3abfe571b11c0c96c49896cf.zip
RustAndDust-47fa20f6ae602fcd3abfe571b11c0c96c49896cf.tar.gz
Pawn: add boolean canBeAttacked(Pawn other)
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java1
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java1
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java6
3 files changed, 8 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index 402a8e0..b1eb382 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -280,6 +280,7 @@ public abstract class Board implements Disposable
targets.clear();
while (units.hasNext()) {
Pawn target = units.next();
+ if (!target.canBeAttacked(pawn)) continue;
Tile to = target.getTile();
if (searchBoard.buildAttack(pawn, true, target, from.getCol(), from.getRow(), to.getCol(), to.getRow()))
targets.add(target);
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java
index 4d6299f..4439b31 100644
--- a/core/src/ch/asynk/tankontank/engine/Pawn.java
+++ b/core/src/ch/asynk/tankontank/engine/Pawn.java
@@ -62,6 +62,7 @@ public abstract class Pawn implements Moveable, Disposable
public abstract boolean canRotate();
public abstract boolean canAttack();
public abstract boolean canAttack(Pawn other);
+ public abstract boolean canBeAttacked(Pawn other);
public abstract boolean canAssistAttackWithoutLos();
public abstract void move(int cost);
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index 11ab4e6..f950a1a 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -195,6 +195,12 @@ public class Unit extends HeadedPawn
}
@Override
+ public boolean canBeAttacked(Pawn other)
+ {
+ return true;
+ }
+
+ @Override
public void rotate(Orientation o)
{
hasMoved = true;