diff options
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Board.java | 12 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/game/Map.java | 2 |
2 files changed, 8 insertions, 6 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index 09cfc7d..88a63ec 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -288,17 +288,19 @@ public abstract class Board implements Disposable return targets.size(); } - protected int buildMoveAssists(Pawn pawn, TileCollection assists) + protected int collectMoveAssists(Pawn pawn, PawnCollection assists) { assists.clear(); setAdjacentTiles(pawn.getTile(), neighbours); for (int i = 0; i < 6; i++) { Tile t = neighbours[i]; if (t != null) { - // FIXME should support may pawns per tile - Pawn p = t.getTopPawn(); - if ((p != null) && p.canMove() && !pawn.isEnemy(p)) - assists.add(p.getTile()); + Iterator<Pawn> pawns = t.iterator(); + while(pawns.hasNext()) { + Pawn p = pawns.next(); + if ((p != null) && p.canMove() && !pawn.isEnemy(p)) + assists.add(p); + } } } return assists.size(); diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java index 27e70bc..c8c80bc 100644 --- a/core/src/ch/asynk/tankontank/game/Map.java +++ b/core/src/ch/asynk/tankontank/game/Map.java @@ -165,7 +165,7 @@ public abstract class Map extends Board public int collectMoveablePawns(Pawn pawn) { if (pawn.isHq()) { - buildMoveAssists(pawn, moveablePawns); + collectMoveAssists(pawn, moveablePawns); } else { moveablePawns.clear(); } |