summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-11-05 14:23:03 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-11-05 14:23:03 +0100
commit9ef6e1b0bb5e8d8098b2be7daae7e77e4dab55d5 (patch)
treec791a661af5876d199db9d3a727eb2ee99ed88f1
parent25033e52443218e53104220a834bebd1cb385f3c (diff)
downloadRustAndDust-9ef6e1b0bb5e8d8098b2be7daae7e77e4dab55d5.zip
RustAndDust-9ef6e1b0bb5e8d8098b2be7daae7e77e4dab55d5.tar.gz
add and use Pawn.preventDefenseOn(Tile)
-rw-r--r--core/src/ch/asynk/rustanddust/engine/Pawn.java1
-rw-r--r--core/src/ch/asynk/rustanddust/game/Map.java2
-rw-r--r--core/src/ch/asynk/rustanddust/game/Unit.java9
3 files changed, 11 insertions, 1 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/Pawn.java b/core/src/ch/asynk/rustanddust/engine/Pawn.java
index 09b49aa..f21c9b9 100644
--- a/core/src/ch/asynk/rustanddust/engine/Pawn.java
+++ b/core/src/ch/asynk/rustanddust/engine/Pawn.java
@@ -48,6 +48,7 @@ public abstract class Pawn implements Moveable, Disposable
public abstract int getFlankSides();
public abstract int getEngagementRangeFrom(Tile tile);
public abstract int getDefense(Tile tile);
+ public abstract boolean preventDefenseOn(Tile tile);
public abstract boolean isUnit();
public abstract boolean isA(PawnId id);
diff --git a/core/src/ch/asynk/rustanddust/game/Map.java b/core/src/ch/asynk/rustanddust/game/Map.java
index 62f5723..e4f44e6 100644
--- a/core/src/ch/asynk/rustanddust/game/Map.java
+++ b/core/src/ch/asynk/rustanddust/game/Map.java
@@ -494,7 +494,7 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
mayReroll = true;
if (unit.isFlankAttack())
flankAttack = true;
- if (unit.isA(Unit.UnitType.INFANTRY))
+ if (unit.preventDefenseOn(e.defender.getTile()))
terrainBonus = false;
if (night) {
if (distance < unit.attackDistance())
diff --git a/core/src/ch/asynk/rustanddust/game/Unit.java b/core/src/ch/asynk/rustanddust/game/Unit.java
index cbc3842..36e6a69 100644
--- a/core/src/ch/asynk/rustanddust/game/Unit.java
+++ b/core/src/ch/asynk/rustanddust/game/Unit.java
@@ -182,6 +182,15 @@ public class Unit extends HeadedPawn
}
@Override
+ public boolean preventDefenseOn(Tile tile)
+ {
+ if (isA(UnitType.INFANTRY) && (tile.isA(Terrain.WOODS) || tile.isA(Terrain.TOWN)))
+ return true;
+
+ return false;
+ }
+
+ @Override
public boolean isUnit()
{
return true;