summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-02-18 12:00:27 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-02-18 12:00:27 +0100
commit30a2d67036412ecb5f3ba08ef6fcaeebc7b346af (patch)
tree78476074fb02841685b4766fd6cb5fbddc8adc94 /core/src/ch/asynk
parent9ed71f01974aefe888e54b7c099852ecd8323bb7 (diff)
downloadRustAndDust-30a2d67036412ecb5f3ba08ef6fcaeebc7b346af.zip
RustAndDust-30a2d67036412ecb5f3ba08ef6fcaeebc7b346af.tar.gz
Board,Map: add attack(Pawn, Pawn, boolean) to recompute and validate attack
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java6
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java1
2 files changed, 7 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index b8aead6..a097454 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -465,6 +465,12 @@ public abstract class Board implements Disposable, Animation
pawn.revertLastMove();
}
+ public void attack(final Pawn pawn, final Pawn target, boolean clearVisibility)
+ {
+ if (!pawn.canEngage(target) || !searchBoard.canAttack(pawn, target, clearVisibility))
+ throw new RuntimeException(String.format("%s cannot attack %s", pawn, target));
+ }
+
public Tile getTileAt(float mx, float my)
{
// compute row
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 2ef7749..b3b1ed3 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -544,6 +544,7 @@ public abstract class Map extends Board implements MoveToAnimationCb, ObjectiveS
public boolean engageUnit(Unit unit, final Unit target)
{
+ attack(unit, target, true);
boolean success = resolveFight(unit, target, engagement);