diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-17 16:22:00 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-17 16:22:00 +0100 |
commit | a6e98214664d0628d43b8bd487888b61b6b9d1b3 (patch) | |
tree | a836b6600c869a3510ec79b22972771709138ada /core | |
parent | a31850c31c0f2f70e9bd191f6d69f43abd619696 (diff) | |
download | RustAndDust-a6e98214664d0628d43b8bd487888b61b6b9d1b3.zip RustAndDust-a6e98214664d0628d43b8bd487888b61b6b9d1b3.tar.gz |
Hex: use isA(...)
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java index 7abf0d3..0499924 100644 --- a/core/src/ch/asynk/tankontank/game/Hex.java +++ b/core/src/ch/asynk/tankontank/game/Hex.java @@ -9,6 +9,7 @@ import ch.asynk.tankontank.engine.Board; import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.engine.Tile; import ch.asynk.tankontank.engine.Orientation; +import ch.asynk.tankontank.game.Unit.UnitType; public class Hex extends Tile { @@ -60,16 +61,16 @@ public class Hex extends Tile @Override public boolean isOffMap() { - return terrain == Terrain.OFFMAP; + return isA(Terrain.OFFMAP); } @Override public boolean blockLineOfSightFrom(Tile tile) { - if ((terrain == Terrain.CLEAR) && !hasUnits()) + if (isA(Terrain.CLEAR) && !hasUnits()) return false; - if ((((Hex) tile).terrain == Terrain.HILLS) && (terrain == Terrain.CLEAR)) + if (tile.isA(Terrain.HILLS) && isA(Terrain.CLEAR)) return false; return true; @@ -78,7 +79,7 @@ public class Hex extends Tile @Override public boolean atLeastOneMove(Pawn pawn) { - if (hasUnits() || (terrain == Terrain.BLOCKED) || (terrain == Terrain.OFFMAP)) + if (hasUnits() || isA(Terrain.BLOCKED) || isA(Terrain.OFFMAP)) return false; return true; } @@ -121,7 +122,7 @@ public class Hex extends Tile boolean terrainBonus = true; for (Pawn foe : foes) { - if (((Unit) foe).type == Unit.UnitType.INFANTRY) + if (foe.isA(UnitType.INFANTRY)) terrainBonus = false; } @@ -129,12 +130,12 @@ public class Hex extends Tile int def = u.def; switch(terrain) { case HILLS: - if (u.type != Unit.UnitType.HARD_TARGET) + if (!u.isA(UnitType.HARD_TARGET)) def = u.cdef; break; case WOODS: case TOWN: - if (u.type != Unit.UnitType.HARD_TARGET) + if (!u.isA(UnitType.HARD_TARGET)) def = u.cdef; if (terrainBonus) tdef = 1; |