diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-28 16:29:45 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-28 16:29:45 +0100 |
commit | 4383cc0ba8fe4ccac0edd22aee5e7a7d88dad442 (patch) | |
tree | fce919a2a4ee2e4ba17f64d3e1343d7fff386872 /core/src/ch/asynk/tankontank/engine | |
parent | 3684b17fb5a8c3ccf725526f446ee90cd94a3406 (diff) | |
download | RustAndDust-4383cc0ba8fe4ccac0edd22aee5e7a7d88dad442.zip RustAndDust-4383cc0ba8fe4ccac0edd22aee5e7a7d88dad442.tar.gz |
Tile: getIterator() -> iterator(), getTopPawn() goes private
Diffstat (limited to 'core/src/ch/asynk/tankontank/engine')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Tile.java | 8 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/TileList.java | 10 | ||||
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/TileSet.java | 11 |
3 files changed, 18 insertions, 11 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Tile.java b/core/src/ch/asynk/tankontank/engine/Tile.java index f1e2c12..0514c6d 100644 --- a/core/src/ch/asynk/tankontank/engine/Tile.java +++ b/core/src/ch/asynk/tankontank/engine/Tile.java @@ -64,7 +64,7 @@ public abstract class Tile implements Drawable, Disposable return stack.isEmpty(); } - public Iterator<Pawn> getIterator() + public Iterator<Pawn> iterator() { return stack.iterator(); } @@ -82,7 +82,7 @@ public abstract class Tile implements Drawable, Disposable return stack.size(); } - public Pawn getTopPawn() + private Pawn getTopPawn() { if (isEmpty()) return null; return stack.getFirst(); @@ -91,7 +91,7 @@ public abstract class Tile implements Drawable, Disposable public boolean hasUnits() { if (isEmpty()) return false; - Iterator<Pawn> itr = getIterator(); + Iterator<Pawn> itr = iterator(); while(itr.hasNext()) { if (itr.next().isUnit()) return true; @@ -102,7 +102,7 @@ public abstract class Tile implements Drawable, Disposable public boolean hasTargetsFor(Pawn pawn) { if (isEmpty()) return false; - Iterator<Pawn> itr = getIterator(); + Iterator<Pawn> itr = iterator(); while(itr.hasNext()) { Pawn target = itr.next(); if (pawn.canAttack(target)) return true; diff --git a/core/src/ch/asynk/tankontank/engine/TileList.java b/core/src/ch/asynk/tankontank/engine/TileList.java index 0e56aac..6c5b2e5 100644 --- a/core/src/ch/asynk/tankontank/engine/TileList.java +++ b/core/src/ch/asynk/tankontank/engine/TileList.java @@ -1,8 +1,9 @@ package ch.asynk.tankontank.engine; +import java.util.Iterator; +import java.util.Collection; import java.util.List; import java.util.ArrayList; -import java.util.Collection; public class TileList extends ArrayList<Tile> implements Board.TileCollection { @@ -40,8 +41,11 @@ public class TileList extends ArrayList<Tile> implements Board.TileCollection public void getPawns(Collection<Pawn> pawns) { pawns.clear(); - for (Tile tile : this) - pawns.add(tile.getTopPawn()); + for (Tile tile : this) { + Iterator<Pawn> itr = tile.iterator(); + while(itr.hasNext()) + pawns.add(itr.next()); + } } public int fromNodes(Collection<SearchBoard.Node> nodes) diff --git a/core/src/ch/asynk/tankontank/engine/TileSet.java b/core/src/ch/asynk/tankontank/engine/TileSet.java index 71fd39d..07dc8ad 100644 --- a/core/src/ch/asynk/tankontank/engine/TileSet.java +++ b/core/src/ch/asynk/tankontank/engine/TileSet.java @@ -1,8 +1,8 @@ package ch.asynk.tankontank.engine; -import java.util.Set; -import java.util.LinkedHashSet; +import java.util.Iterator; import java.util.Collection; +import java.util.LinkedHashSet; public class TileSet extends LinkedHashSet<Tile> implements Board.TileCollection { @@ -40,8 +40,11 @@ public class TileSet extends LinkedHashSet<Tile> implements Board.TileCollection public void getPawns(Collection<Pawn> pawns) { pawns.clear(); - for (Tile tile : this) - pawns.add(tile.getTopPawn()); + for (Tile tile : this) { + Iterator<Pawn> itr = tile.iterator(); + while(itr.hasNext()) + pawns.add(itr.next()); + } } public int fromNodes(Collection<SearchBoard.Node> nodes) |