diff options
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Tile.java | 11 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Hex.java | 31 |
2 files changed, 33 insertions, 9 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java index 85987d6..d2bda78 100644 --- a/core/src/ch/asynk/tankontank/engine/Tile.java +++ b/core/src/ch/asynk/tankontank/engine/Tile.java @@ -16,6 +16,10 @@ public abstract class Tile implements BasicDrawable private ArrayDeque<Pawn> stack; public abstract Tile getNewAt(float x, float y); + public abstract boolean atLeastOneMove(Pawn pawn); + public abstract int roadMarchBonus(Pawn pawn); + public abstract boolean road(Board.Orientation side); + public abstract int costFrom(Pawn pawn, Board.Orientation side, boolean road); public Tile(TextureAtlas atlas) { @@ -72,13 +76,6 @@ public abstract class Tile implements BasicDrawable return mustBeDrawn(); } - public List<Tile> adjacents() - { - // FIXME - System.err.println("adjacents() Not implemented yet"); - return null; - } - @Override public void translate(float x, float y) { diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java index 404f763..6666e9a 100644 --- a/core/src/ch/asynk/tankontank/game/Hex.java +++ b/core/src/ch/asynk/tankontank/game/Hex.java @@ -2,6 +2,7 @@ package ch.asynk.tankontank.game; import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import ch.asynk.tankontank.engine.Pawn; import ch.asynk.tankontank.engine.Tile; import ch.asynk.tankontank.engine.Board; @@ -43,9 +44,31 @@ public class Hex extends Tile Hex.atlas = atlas; } - public int costFrom(Board.Orientation side) + @Override + public boolean atLeastOneMove(Pawn pawn) + { + if (occupied() || (terrain == Terrain.BLOCKED) || (terrain == Terrain.OFFMAP)) + return false; + return true; + } + + @Override + public int roadMarchBonus(Pawn pawn) + { + return 1; + } + + @Override + public boolean road(Board.Orientation side) { - if (side.s == (roads & side.s)) return 1; + return (side.s == (roads & side.s)); + } + + @Override + public int costFrom(Pawn pawn, Board.Orientation side, boolean road) + { + if (occupied()) return Integer.MAX_VALUE; + if (road) return 1; int c = 0; switch(terrain) { @@ -57,6 +80,10 @@ public class Hex extends Tile case TOWN: c = 2; break; + case OFFMAP: + case BLOCKED: + c = Integer.MAX_VALUE; + break; } return c; |