diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-09 18:42:57 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-09 18:42:57 +0100 |
commit | 9154d76c30f106e4811a99b34f35c8923967195f (patch) | |
tree | ba89574eb57dc730493cbda8ad9648778c6294c6 /core | |
parent | 4e20b4f3336fa2171159d0e92973923c800cdd83 (diff) | |
download | RustAndDust-9154d76c30f106e4811a99b34f35c8923967195f.zip RustAndDust-9154d76c30f106e4811a99b34f35c8923967195f.tar.gz |
Tile: stack is private and is an ArrayListIt
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/Tile.java | 18 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/game/Hex.java | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/Tile.java b/core/src/ch/asynk/rustanddust/engine/Tile.java index e602944..3c931cd 100644 --- a/core/src/ch/asynk/rustanddust/engine/Tile.java +++ b/core/src/ch/asynk/rustanddust/engine/Tile.java @@ -1,7 +1,6 @@ package ch.asynk.rustanddust.engine; import java.util.Iterator; -import java.util.ArrayDeque; import com.badlogic.gdx.utils.Disposable; @@ -9,6 +8,7 @@ import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; +import ch.asynk.rustanddust.engine.util.ArrayListIt; import ch.asynk.rustanddust.engine.gfx.Drawable; import ch.asynk.rustanddust.engine.gfx.StackedImages; @@ -31,7 +31,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn> protected float x; protected float y; private StackedImages overlays; - protected ArrayDeque<Pawn> stack; + private ArrayListIt<Pawn> stack; protected Faction curFaction; protected Faction prevFaction; @@ -51,7 +51,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn> { this.col = col; this.row = row; - this.stack = new ArrayDeque<Pawn>(); + this.stack = new ArrayListIt<Pawn>(); this.curFaction = defaultFaction; this.prevFaction = defaultFaction; this.objective = Objective.NONE; @@ -96,6 +96,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn> return stack.isEmpty(); } + @Override public Iterator<Pawn> iterator() { return stack.iterator(); @@ -104,7 +105,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn> public int push(Pawn pawn) { if (!stack.contains(pawn)) - stack.push(pawn); + stack.add(pawn); return stack.size(); } @@ -114,18 +115,17 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn> return stack.size(); } - private Pawn getTopPawn() + protected Pawn getTopPawn() { if (isEmpty()) return null; - return stack.getFirst(); + return stack.get(stack.size() - 1); } public boolean hasUnits() { if (isEmpty()) return false; - Iterator<Pawn> itr = iterator(); - while (itr.hasNext()) { - if (itr.next().isUnit()) + for (Pawn p : this) { + if (p.isUnit()) return true; } return false; diff --git a/core/src/ch/asynk/rustanddust/game/Hex.java b/core/src/ch/asynk/rustanddust/game/Hex.java index 2bfbc94..f5a990e 100644 --- a/core/src/ch/asynk/rustanddust/game/Hex.java +++ b/core/src/ch/asynk/rustanddust/game/Hex.java @@ -52,7 +52,7 @@ public class Hex extends Tile public Unit getUnit() { - return (Unit) stack.peekFirst(); + return (Unit) getTopPawn(); } @Override |