summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/src/ch/asynk/tankontank/engine/Tile.java8
-rw-r--r--core/src/ch/asynk/tankontank/engine/TileList.java10
-rw-r--r--core/src/ch/asynk/tankontank/engine/TileSet.java11
-rw-r--r--core/src/ch/asynk/tankontank/game/Hex.java3
4 files changed, 19 insertions, 13 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)
diff --git a/core/src/ch/asynk/tankontank/game/Hex.java b/core/src/ch/asynk/tankontank/game/Hex.java
index 86c511b..77b8bfd 100644
--- a/core/src/ch/asynk/tankontank/game/Hex.java
+++ b/core/src/ch/asynk/tankontank/game/Hex.java
@@ -47,8 +47,7 @@ public class Hex extends Tile
public Unit getUnit()
{
- // FIXME ??????
- return (Unit) getTopPawn();
+ return (Unit) iterator().next();
}
@Override