summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-13 00:20:06 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-13 00:20:06 +0200
commit821a6d96a5306fab7cb31211f587623af4f3925f (patch)
treef0fd95b38f7bb79796c8dddf9243f99bead36a98
parenta4275a3391f860d78d853c7f578ad23e5300a810 (diff)
downloadRustAndDust-821a6d96a5306fab7cb31211f587623af4f3925f.zip
RustAndDust-821a6d96a5306fab7cb31211f587623af4f3925f.tar.gz
SearchBoard: add canAttack(Pawn, int, int, int, int)
-rw-r--r--core/src/ch/asynk/tankontank/engine/SearchBoard.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/SearchBoard.java b/core/src/ch/asynk/tankontank/engine/SearchBoard.java
index d7e0208..df3c68b 100644
--- a/core/src/ch/asynk/tankontank/engine/SearchBoard.java
+++ b/core/src/ch/asynk/tankontank/engine/SearchBoard.java
@@ -345,6 +345,16 @@ public class SearchBoard
return targets;
}
+ public boolean canAttack(Pawn pawn, int col0, int row0, int col1, int row1)
+ {
+ Node from = getNode(col0, row0);
+ Node to = getNode(col1, row1);
+ Tile tile = board.getTile(col0, row0);
+
+ if (distance(from, to) > pawn.getAttackRangeFrom(tile)) return false;
+ return hasClearLineOfSight(from, to);
+ }
+
private boolean hasClearLineOfSight(Node from, Node to)
{
List<Node> nodes = lineOfSight(from.col, from.row, to.col, to.row);