summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-28 23:35:24 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-28 23:35:24 +0100
commit01c76e439e4b40cab40bd0a9aa3999658209ba55 (patch)
treec225237ba45c71f4d45ca87cf1dbfe0a8b5250b3 /core
parent27ae3693d680528522ee87d2b7905153cf6754a6 (diff)
downloadRustAndDust-01c76e439e4b40cab40bd0a9aa3999658209ba55.zip
RustAndDust-01c76e439e4b40cab40bd0a9aa3999658209ba55.tar.gz
Board: fix buildMoveAssists -> collectMoveAssists
Diffstat (limited to 'core')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java12
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java2
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();
}