diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-18 00:29:14 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-02-18 00:29:14 +0100 |
commit | 7c09767469ca69ebac47e2753da8d31bba585d44 (patch) | |
tree | 7ecc0f295b7625198c6d95e4d0bf8d1ef6b857b0 /core/src/ch/asynk/tankontank | |
parent | 41752ef3daa47df541ed4faef62f0d79aaf009e3 (diff) | |
download | RustAndDust-7c09767469ca69ebac47e2753da8d31bba585d44.zip RustAndDust-7c09767469ca69ebac47e2753da8d31bba585d44.tar.gz |
SearchBoard: collectAttacks -> canAttack(...) do not use Pawn.engagement
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-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; } |