From 9ef6e1b0bb5e8d8098b2be7daae7e77e4dab55d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 5 Nov 2015 14:23:03 +0100 Subject: add and use Pawn.preventDefenseOn(Tile) --- core/src/ch/asynk/rustanddust/engine/Pawn.java | 1 + core/src/ch/asynk/rustanddust/game/Map.java | 2 +- core/src/ch/asynk/rustanddust/game/Unit.java | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) 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; -- cgit v1.1-2-g2b99