summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Tile.java3
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java14
2 files changed, 16 insertions, 1 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java
index 9db279f..7998827 100644
--- a/core/src/ch/asynk/tankontank/engine/Tile.java
+++ b/core/src/ch/asynk/tankontank/engine/Tile.java
@@ -13,12 +13,13 @@ import ch.asynk.tankontank.engine.gfx.StackedImages;
public abstract class Tile implements BasicDrawable
{
private StackedImages overlays;
- private ArrayDeque<Pawn> stack;
+ protected ArrayDeque<Pawn> stack;
public abstract Tile getNewAt(float x, float y);
public abstract boolean atLeastOneMove(Pawn pawn);
public abstract boolean road(Board.Orientation side);
public abstract int costFrom(Pawn pawn, Board.Orientation side, boolean road);
+ public abstract boolean hasTargetsFor(Pawn pawn);
public Tile(TextureAtlas atlas)
{
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index 161ed44..c8c7361 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -1,5 +1,7 @@
package ch.asynk.tankontank.game;
+import java.util.Iterator;
+
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import ch.asynk.tankontank.engine.Pawn;
@@ -82,4 +84,16 @@ public class Hex extends Tile
return c;
}
+
+ @Override
+ public boolean hasTargetsFor(Pawn pawn)
+ {
+ if (!occupied()) return false;
+
+ Iterator<Pawn> itr = stack.iterator();
+ while(itr.hasNext())
+ if (itr.next().isEnemy(pawn)) return true;
+
+ return false;
+ }
}