summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-09-24 12:25:36 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-09-24 12:25:36 +0200
commitae64c344880b14ecb3984ec23d5f3620d2d09c2c (patch)
tree4337e4e25f6906b3ea412b52710cdce72983ac43 /core
parentcab965d2ab476346be8ae2c3ba7f22e5207e6fbe (diff)
downloadRustAndDust-ae64c344880b14ecb3984ec23d5f3620d2d09c2c.zip
RustAndDust-ae64c344880b14ecb3984ec23d5f3620d2d09c2c.tar.gz
Tile and Hex: atLeastOneMove(), roadMarchBonus(), road(), costFrom()
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Tile.java11
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java31
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;