summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/tankontank
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-28 12:20:12 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-28 12:20:12 +0100
commit4b28bdb354e063d9bddf864d6a902957d01382f1 (patch)
tree3d7bfc5f54f8cf22fd4af65f38cf93eea6f0fbe5 /core/src/ch/asynk/tankontank
parenta97645fa17992b0f87cbb9e9a0801e3b44479ca5 (diff)
downloadRustAndDust-4b28bdb354e063d9bddf864d6a902957d01382f1.zip
RustAndDust-4b28bdb354e063d9bddf864d6a902957d01382f1.tar.gz
add TileSet extends LinkedHashSet<Tile> implements Board.TileCollection
Diffstat (limited to 'core/src/ch/asynk/tankontank')
-rw-r--r--core/src/ch/asynk/tankontank/engine/TileSet.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/TileSet.java b/core/src/ch/asynk/tankontank/engine/TileSet.java
new file mode 100644
index 0000000..71fd39d
--- /dev/null
+++ b/core/src/ch/asynk/tankontank/engine/TileSet.java
@@ -0,0 +1,57 @@
+package ch.asynk.tankontank.engine;
+
+import java.util.Set;
+import java.util.LinkedHashSet;
+import java.util.Collection;
+
+public class TileSet extends LinkedHashSet<Tile> implements Board.TileCollection
+{
+ private final Board board;
+ private int overlay;
+
+ public TileSet(Board board, int overlay, int n)
+ {
+ super(n);
+ this.board = board;
+ this.overlay = overlay;
+ }
+
+ public Tile first()
+ {
+ return iterator().next();
+ }
+
+ public void show()
+ {
+ enable(overlay, true);
+ }
+
+ public void hide()
+ {
+ enable(overlay, false);
+ }
+
+ public void enable(int i, boolean enable)
+ {
+ for (Tile tile : this)
+ board.enableOverlayOn(tile, i, enable);
+ }
+
+ public void getPawns(Collection<Pawn> pawns)
+ {
+ pawns.clear();
+ for (Tile tile : this)
+ pawns.add(tile.getTopPawn());
+ }
+
+ public int fromNodes(Collection<SearchBoard.Node> nodes)
+ {
+ clear();
+ for (SearchBoard.Node node : nodes) {
+ Tile tile = board.getTile(node.col, node.row);
+ add(tile);
+ }
+
+ return size();
+ }
+}