diff options
Diffstat (limited to 'core/src/ch')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/SearchBoard.java | 10 |
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); |