summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-13 16:56:23 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-13 16:56:23 +0200
commitb6b7853f387b6cf0d052cc99bfddd22793bbec2c (patch)
tree8d92512f707d6b01a0eddfc5073b98eacf8718b0 /core
parentcb5e7eb16dafeecb9c1750139af873a5d0d148c1 (diff)
downloadRustAndDust-b6b7853f387b6cf0d052cc99bfddd22793bbec2c.zip
RustAndDust-b6b7853f387b6cf0d052cc99bfddd22793bbec2c.tar.gz
Board: buildAttackAssists(...) -> buildAttack() returns the count of possible assists
Diffstat (limited to 'core')
-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)