summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-08 09:33:36 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-08 09:33:36 +0200
commit50512b7bdd11138d7c5d74ad94f4c280c7e36f66 (patch)
treef5b44a1a7bc25e43fd822f295cf4791e94dac263 /core
parentb4d813b03ceda804bb2c4aca092809fa4e06e52c (diff)
downloadRustAndDust-50512b7bdd11138d7c5d74ad94f4c280c7e36f66.zip
RustAndDust-50512b7bdd11138d7c5d74ad94f4c280c7e36f66.tar.gz
Board: add buildMoveAssists(), possibleMovesFrom()->buildPossibleMovesFrom(), possibleTargetsFrom()->buildPossibleTargetsFrom()
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index 4227f53..3b5ef79 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -313,18 +313,33 @@ public abstract class Board implements Disposable
}
}
- public void possibleMovesFrom(Pawn pawn, GridPoint2 coords, ArrayList<GridPoint2> moves)
+ public void buildPossibleMovesFrom(Pawn pawn, GridPoint2 coords, ArrayList<GridPoint2> moves)
{
List<SearchBoard.Node> nodes = searchBoard.possibleMovesFrom(pawn, coords.x, coords.y);
nodesToPoints(nodes, moves);
}
- public void possibleTargetsFrom(Pawn pawn, GridPoint2 coords, ArrayList<GridPoint2> targets)
+ public void buildPossibleTargetsFrom(Pawn pawn, GridPoint2 coords, ArrayList<GridPoint2> targets)
{
List<SearchBoard.Node> nodes = searchBoard.possibleTargetsFrom(pawn, coords.x, coords.y);
nodesToPoints(nodes, targets);
}
+ public void buildMoveAssists(Pawn pawn, GridPoint2 coords, List<GridPoint2> assists)
+ {
+ assists.clear();
+ buildNeighboursFor(coords);
+ for (int i = 0; i < 6; i++) {
+ GridPoint2 neighbour = neighbours[i];
+ Tile t = getTileSafe(neighbour);
+ if (t != null) {
+ Pawn p = t.getTopPawn();
+ if ((p != null) && (!pawn.isEnemy(p)))
+ assists.add(neighbour);
+ }
+ }
+ }
+
public void clearPointSet(Set<GridPoint2> points)
{
for (GridPoint2 point : points)