diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-13 00:30:20 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-13 00:30:20 +0200 |
commit | 27ddaf24edbc47498416b61d216a0f93d2de0e0d (patch) | |
tree | a4b7e89e40e8f90f562165284c88874984f90c71 /core | |
parent | a7cc12cff89ec38bc3e1902f83bbd6efcf4121e4 (diff) | |
download | RustAndDust-27ddaf24edbc47498416b61d216a0f93d2de0e0d.zip RustAndDust-27ddaf24edbc47498416b61d216a0f93d2de0e0d.tar.gz |
Board: add buildAttackAssists(Pawn, GridPoint2, Iterator<Pawn>, ArrayList<GridPoint2>)
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 7493059..8142fab 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -343,6 +343,26 @@ public abstract class Board implements Disposable } } + protected void buildAttackAssists(Pawn pawn, 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 (from == null) + from = gridPoint2Pool.obtain(); + getHexAt(p.getPosition(), from); + if (searchBoard.canAttack(p, from.x, from.y, hex.x, hex.y)) { + assists.add(from); + from = null; + } + } + + if (from != null) gridPoint2Pool.free(from); + } + protected void clearPointSet(Set<GridPoint2> points) { for (GridPoint2 point : points) |