summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index 6c5fb63..8ad214b 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -346,24 +346,28 @@ public abstract class Board implements Disposable
return assists.size();
}
- protected void buildAttackAssists(Pawn pawn, GridPoint2 hex, Iterator<Pawn> units, ArrayList<GridPoint2> assists)
+ protected int buildAttack(Pawn pawn, Pawn target, GridPoint2 hex, Iterator<Pawn> units, ArrayList<GridPoint2> assists)
{
clearPointVector(assists);
GridPoint2 from = null;
while (units.hasNext()) {
Pawn p = units.next();
- if ((p == pawn) || !p.canAttack()) continue;
+ if (!p.canAttack()) continue;
if (from == null)
from = gridPoint2Pool.obtain();
getHexUnder(p, from);
- if (searchBoard.canAttack(p, from.x, from.y, hex.x, hex.y)) {
- assists.add(from);
- from = null;
+ if (searchBoard.buildAttack(p, target, from.x, from.y, hex.x, hex.y)) {
+ if (p != pawn) {
+ assists.add(from);
+ from = null;
+ }
}
}
if (from != null) gridPoint2Pool.free(from);
+
+ return assists.size();
}
protected void clearPointSet(Set<GridPoint2> points)