summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/tankontank/engine/Tile.java7
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java33
2 files changed, 38 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java
index fdcc61e..88edd4f 100644
--- a/core/src/ch/asynk/tankontank/engine/Tile.java
+++ b/core/src/ch/asynk/tankontank/engine/Tile.java
@@ -1,5 +1,6 @@
package ch.asynk.tankontank.engine;
+import java.util.List;
import java.util.Iterator;
import java.util.ArrayDeque;
@@ -19,10 +20,12 @@ public abstract class Tile implements Drawable, Disposable
private StackedImages overlays;
private ArrayDeque<Pawn> stack;
+ public abstract int defenseFor(Pawn target, List<Pawn> foes);
public abstract int costFrom(Pawn pawn, Orientation side, boolean road);
- public abstract boolean atLeastOneMove(Pawn pawn);
- public abstract boolean road(Orientation side);
+
public abstract boolean isOffMap();
+ public abstract boolean road(Orientation side);
+ public abstract boolean atLeastOneMove(Pawn pawn);
public abstract boolean blockLineOfSightFrom(Tile tile);
protected Tile()
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index d61d601..e54574d 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -1,5 +1,6 @@
package ch.asynk.tankontank.game;
+import java.util.List;
import java.util.Iterator;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
@@ -100,4 +101,36 @@ public class Hex extends Tile
return c;
}
+
+ @Override
+ public int defenseFor(Pawn target, List<Pawn> foes)
+ {
+ Unit u = (Unit) target;
+ boolean terrainBonus = true;
+
+ for (Pawn foe : foes) {
+ if (((Unit) foe).type == Unit.UnitType.INFANTRY)
+ terrainBonus = false;
+ }
+
+ int def = u.def;
+ switch(terrain) {
+ case HILLS:
+ if (u.type != Unit.UnitType.HARD_TARGET)
+ def = u.cdef;
+ break;
+ case WOODS:
+ case TOWN:
+ if (u.type != Unit.UnitType.HARD_TARGET)
+ def = u.cdef;
+ if (terrainBonus)
+ def += 1;
+ break;
+ default:
+ def = ((Unit) target).def;
+ break;
+ }
+
+ return def;
+ }
}