diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 4 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/SearchBoard.java | 11 |
2 files changed, 5 insertions, 10 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 121811a..b8aead6 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -309,7 +309,7 @@ public abstract class Board implements Disposable, Animation { targets.clear(); for (Pawn target : units) { - if (pawn.canEngage(target) && searchBoard.collectAttacks(pawn, target, true)) + if (pawn.canEngage(target) && searchBoard.canAttack(pawn, target, true)) targets.add(target); } @@ -338,7 +338,7 @@ public abstract class Board implements Disposable, Animation { assists.clear(); for (Pawn p : units) { - if ((p != pawn) && p.canEngage(target) && searchBoard.collectAttacks(p, target, !p.canAssistEngagementWithoutLos())) + if ((p != pawn) && p.canEngage(target) && searchBoard.canAttack(p, target, !p.canAssistEngagementWithoutLos())) assists.add(p); } diff --git a/core/src/ch/asynk/tankontank/engine/SearchBoard.java b/core/src/ch/asynk/tankontank/engine/SearchBoard.java index 370fc89..fcd7a58 100644 --- a/core/src/ch/asynk/tankontank/engine/SearchBoard.java +++ b/core/src/ch/asynk/tankontank/engine/SearchBoard.java @@ -321,16 +321,14 @@ public class SearchBoard return targets.size(); } - public boolean collectAttacks(Pawn pawn, Pawn target, boolean clearVisibility) + public boolean canAttack(Pawn pawn, Pawn target, boolean clearVisibility) { Node from = getNode(pawn.getTile()); Node to = getNode(target.getTile()); - pawn.engagement.isClear = false; - pawn.engagement.target = target; - pawn.engagement.distance = distance(from, to); + int distance = distance(from, to); - if (pawn.engagement.distance > pawn.getEngagementRangeFrom(pawn.getTile())) + if (distance > pawn.getEngagementRangeFrom(pawn.getTile())) return false; List<Node> los = lineOfSight(from.col, from.row, to.col, to.row, clearVisibility); @@ -341,9 +339,6 @@ public class SearchBoard if (!validatePathAngle(pawn.getAngleOfAttack(), los)) return false; - pawn.engagement.isClear = true; - pawn.engagement.isFlank = isFlankAttack(target.getFlankSides(), los); - return true; } |