summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/engine/TileList.java70
-rw-r--r--core/src/ch/asynk/tankontank/game/HexList.java11
2 files changed, 81 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/TileList.java b/core/src/ch/asynk/tankontank/engine/TileList.java
new file mode 100644
index 0000000..d8584cb
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/engine/TileList.java
@@ -0,0 +1,70 @@
+package ch.asynk.tankontank.engine;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class TileList
+{
+ private final Board board;
+ private final List<Tile> tiles;
+
+ public TileList(Board board, int n)
+ {
+ this.board = board;
+ this.tiles = new ArrayList<Tile>(n);
+ }
+
+ public int fromNodes(List<SearchBoard.Node> nodes)
+ {
+ tiles.clear();
+ for (SearchBoard.Node node : nodes) {
+ Tile tile = board.getTileSafe(node.col, node.row);
+ tiles.add(tile);
+ }
+
+ return tiles.size();
+ }
+
+ public int size()
+ {
+ return tiles.size();
+ }
+
+ public void clear()
+ {
+ tiles.clear();
+ }
+
+ public Tile get(int i)
+ {
+ return tiles.get(i);
+ }
+
+ public void add(Tile tile)
+ {
+ tiles.add(tile);
+ }
+
+ public boolean remove(Tile tile)
+ {
+ return tiles.remove(tile);
+ }
+
+ public boolean contains(Tile tile)
+ {
+ return tiles.contains(tile);
+ }
+
+ public void enable(int i, boolean enable)
+ {
+ for (Tile tile : tiles)
+ board.enableOverlayOn(tile, i, enable);
+ }
+
+ public void getPawns(List<Pawn> pawns)
+ {
+ pawns.clear();
+ for (Tile tile : tiles)
+ pawns.add(tile.getTopPawn());
+ }
+}
diff --git a/core/src/ch/asynk/tankontank/game/HexList.java b/core/src/ch/asynk/tankontank/game/HexList.java
new file mode 100644
index 0000000..0be4a7d
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/game/HexList.java
@@ -0,0 +1,11 @@
+package ch.asynk.tankontank.game;
+
+import ch.asynk.tankontank.engine.TileList;
+
+public class HexList extends TileList
+{
+ public HexList(Map map, int n)
+ {
+ super(map, n);
+ }
+}