From 01c76e439e4b40cab40bd0a9aa3999658209ba55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 28 Oct 2014 23:35:24 +0100 Subject: Board: fix buildMoveAssists -> collectMoveAssists --- core/src/ch/asynk/tankontank/engine/Board.java | 12 +++++++----- 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 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(); } -- cgit v1.1-2-g2b99