summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-23 21:00:27 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-23 21:00:27 +0200
commita03226aa0991ae72336da23f249f74e9c24dff8f (patch)
treeb57c855dbec936baa916a444548638fd93e59532 /core
parentaf03ccbdc02fa34a82f8a17e228df5ea26b87c38 (diff)
downloadRustAndDust-a03226aa0991ae72336da23f249f74e9c24dff8f.zip
RustAndDust-a03226aa0991ae72336da23f249f74e9c24dff8f.tar.gz
add TileList and HexList
Diffstat (limited to 'core')
-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);
+ }
+}