summaryrefslogtreecommitdiffstats
path: root/core/src
diff options
context:
space:
mode:
Diffstat (limited to 'core/src')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Tile.java26
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java8
2 files changed, 23 insertions, 11 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java
index c5ca8b1..f82c414 100644
--- a/core/src/ch/asynk/tankontank/engine/Tile.java
+++ b/core/src/ch/asynk/tankontank/engine/Tile.java
@@ -1,6 +1,7 @@
package ch.asynk.tankontank.engine;
import java.util.List;
+import java.util.Iterator;
import java.util.ArrayDeque;
import com.badlogic.gdx.graphics.g2d.Batch;
@@ -60,22 +61,33 @@ public abstract class Tile implements Drawable
return stack.getFirst();
}
- public boolean mustBeDrawn()
+ public boolean hasUnits()
{
- if (occupied()) return true;
- return hasOverlayEnabled();
+ if (isEmpty()) return false;
+ Iterator<Pawn> itr = stack.iterator();
+ while(itr.hasNext()) {
+ if (itr.next().isUnit())
+ return true;
+ }
+ return false;
}
- public boolean occupied()
+ public boolean isEmpty()
{
- if (stack == null) return false;
- return (stack.size() != 0);
+ if (stack == null) return true;
+ return (stack.size() == 0);
+ }
+
+ public boolean mustBeDrawn()
+ {
+ if (!isEmpty()) return true;
+ return hasOverlayEnabled();
}
public boolean disableOverlays()
{
overlays.disableAll();
- return occupied();
+ return !isEmpty();
}
public boolean hasOverlayEnabled()
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index 4e07492..238f47a 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -44,7 +44,7 @@ public class Hex extends Tile
@Override
public boolean blockLineOfSightFrom(Tile tile)
{
- if ((terrain == Terrain.CLEAR) && !occupied())
+ if ((terrain == Terrain.CLEAR) && !hasUnits())
return false;
if ((((Hex) tile).terrain == Terrain.HILLS) && (terrain == Terrain.CLEAR))
@@ -56,7 +56,7 @@ public class Hex extends Tile
@Override
public boolean atLeastOneMove(Pawn pawn)
{
- if (occupied() || (terrain == Terrain.BLOCKED) || (terrain == Terrain.OFFMAP))
+ if (hasUnits() || (terrain == Terrain.BLOCKED) || (terrain == Terrain.OFFMAP))
return false;
return true;
}
@@ -70,7 +70,7 @@ public class Hex extends Tile
@Override
public int costFrom(Pawn pawn, Board.Orientation side, boolean road)
{
- if (occupied()) return Integer.MAX_VALUE;
+ if (hasUnits()) return Integer.MAX_VALUE;
if (road) return 1;
int c = 0;
@@ -95,7 +95,7 @@ public class Hex extends Tile
@Override
public boolean hasTargetsFor(Pawn pawn)
{
- if (!occupied()) return false;
+ if (!hasUnits()) return false;
Iterator<Pawn> itr = stack.iterator();
while(itr.hasNext())