diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-30 17:31:37 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-09-30 17:31:37 +0200 |
commit | 49a39415a4f51799ec2272fde507981653c9b3c6 (patch) | |
tree | 1bd01350b14effa482039261ce27fb7602724eb6 /core | |
parent | b0d3dadc59d25fdd2bc85943c64c68615a074553 (diff) | |
download | RustAndDust-49a39415a4f51799ec2272fde507981653c9b3c6.zip RustAndDust-49a39415a4f51799ec2272fde507981653c9b3c6.tar.gz |
Tile: occupied() -> isEmpty() && hasUnits()
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Tile.java | 26 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 8 |
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()) |