summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-17 16:28:57 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-17 16:28:57 +0100
commitc627381b64f2395cbef72c9225e3828d5e7693ec (patch)
treee870922d0d50d24c478b9d93f56b9c288866c646 /core
parenta6e98214664d0628d43b8bd487888b61b6b9d1b3 (diff)
downloadRustAndDust-c627381b64f2395cbef72c9225e3828d5e7693ec.zip
RustAndDust-c627381b64f2395cbef72c9225e3828d5e7693ec.tar.gz
Pawn,Unit: add int getDefense(Tile)
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java1
-rw-r--r--core/src/ch/asynk/tankontank/game/Unit.java9
2 files changed, 10 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java
index 16a74e6..ba4a2bd 100644
--- a/core/src/ch/asynk/tankontank/engine/Pawn.java
+++ b/core/src/ch/asynk/tankontank/engine/Pawn.java
@@ -110,6 +110,7 @@ public abstract class Pawn implements Moveable, Disposable
public abstract int getAngleOfAttack();
public abstract int getFlankSides();
public abstract int getEngagementRangeFrom(Tile tile);
+ public abstract int getDefense(Tile tile);
public abstract boolean isUnit();
public abstract boolean isA(PawnId id);
diff --git a/core/src/ch/asynk/tankontank/game/Unit.java b/core/src/ch/asynk/tankontank/game/Unit.java
index 468589e..c3d613e 100644
--- a/core/src/ch/asynk/tankontank/game/Unit.java
+++ b/core/src/ch/asynk/tankontank/game/Unit.java
@@ -148,6 +148,15 @@ public class Unit extends HeadedPawn
}
@Override
+ public int getDefense(Tile tile)
+ {
+ if (!isHardTarget() && (tile.isA(Hex.Terrain.HILLS) || tile.isA(Hex.Terrain.WOODS) || tile.isA(Hex.Terrain.TOWN)))
+ return cdef;
+
+ return def;
+ }
+
+ @Override
public boolean isUnit()
{
return true;