summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-02-18 11:17:01 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-02-18 11:17:01 +0100
commite60457b93f04a68d041898676966612861ac41a6 (patch)
tree8082bdc82d534452009cd97780ec4ebca45cff10 /core/src/ch/asynk
parent2b19c4b17132cb753430ade0f73727ca2f9ef1be (diff)
downloadRustAndDust-e60457b93f04a68d041898676966612861ac41a6.zip
RustAndDust-e60457b93f04a68d041898676966612861ac41a6.tar.gz
SearchBoard: canAttack(...) set Pawn.attack
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Pawn.java7
-rw-r--r--core/src/ch/asynk/tankontank/engine/SearchBoard.java7
2 files changed, 12 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java
index 716b66b..2986002 100644
--- a/core/src/ch/asynk/tankontank/engine/Pawn.java
+++ b/core/src/ch/asynk/tankontank/engine/Pawn.java
@@ -143,6 +143,13 @@ public abstract class Pawn implements Moveable, Disposable
move();
}
+ public void setAttack(Pawn target, int distance)
+ {
+ attack.reset();
+ attack.target = target;
+ attack.distance = distance;
+ }
+
public boolean justEntered()
{
return ((move != null) && move.isEntry());
diff --git a/core/src/ch/asynk/tankontank/engine/SearchBoard.java b/core/src/ch/asynk/tankontank/engine/SearchBoard.java
index 41516ae..199a7a7 100644
--- a/core/src/ch/asynk/tankontank/engine/SearchBoard.java
+++ b/core/src/ch/asynk/tankontank/engine/SearchBoard.java
@@ -326,9 +326,9 @@ public class SearchBoard
Node from = getNode(pawn.getTile());
Node to = getNode(target.getTile());
- int distance = distance(from, to);
+ pawn.setAttack(target, distance(from, to));
- if (distance > pawn.getEngagementRangeFrom(pawn.getTile()))
+ if (pawn.attack.distance > pawn.getEngagementRangeFrom(pawn.getTile()))
return false;
List<Node> los = lineOfSight(from.col, from.row, to.col, to.row, clearVisibility);
@@ -339,6 +339,9 @@ public class SearchBoard
if (!validatePathAngle(pawn.getAngleOfAttack(), los))
return false;
+ pawn.attack.isClear = isClearAttack(getTile(from), los);
+ pawn.attack.isFlank = isFlankAttack(target.getFlankSides(), los);
+
return true;
}