diff --git a/pom.xml b/pom.xml
index 267c8f9..b8996ba 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,6 +20,13 @@
1.8
+
+
+ clojars
+ http://clojars.org/repo/
+
+
+
@@ -53,6 +60,18 @@
natives-desktop
+
+ com.esotericsoftware
+ kryo
+ 5.0.0-RC5
+
+
+
+ kryonet
+ kryonet
+ 2.21
+
+
junit
junit
diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java
index 8326711..3414d49 100644
--- a/src/main/java/inf112/fiasko/roborally/objects/Board.java
+++ b/src/main/java/inf112/fiasko/roborally/objects/Board.java
@@ -1,10 +1,9 @@
package inf112.fiasko.roborally.objects;
-import inf112.fiasko.roborally.element_properties.Direction;
-import inf112.fiasko.roborally.element_properties.Position;
-import inf112.fiasko.roborally.element_properties.RobotID;
-import inf112.fiasko.roborally.element_properties.TileType;
+import inf112.fiasko.roborally.element_properties.*;
+import inf112.fiasko.roborally.utility.TextureConverterUtil;
+import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -327,4 +326,62 @@ public class Board {
}
return elements;
}
-}
+
+ /**
+ * Gets a list of BoardElementContainers, containing all tiles and positions of given tile types
+ * @param tiles The tiles you want all positions for
+ * @return A list of BoardElementContainers
+ */
+ public List> getPositionsOfTileOnBoard(TileType ... tiles) {
+ List> combinedList = new ArrayList<>();
+ for (TileType tile : tiles) {
+ combinedList.addAll(makeTileList(tile, this.tiles));
+ }
+ return combinedList;
+ }
+
+ /**
+ * Gets a list of BoardElementContainers, containing all tiles and positions of given wall types
+ * @param walls The walls you want all positions for
+ * @return A list of BoardElementContainers
+ */
+ public List> getPositionsOfTileOnBoard(WallType ... walls) {
+ List> combinedList = new ArrayList<>();
+ for (WallType wall : walls) {
+ combinedList.addAll(makeTileList(wall, this.walls));
+ }
+ return combinedList;
+ }
+
+ /**
+ * Finds all position of an obj and makes a list of BoardElementContainers
+ * @param type Type of obj
+ * @param grid Grid to search
+ * @param Type of type
+ * @param Type of grid
+ * @return List of BoardElementContainers
+ */
+ private List> makeTileList(K type, IGrid grid) {
+ List> objList = new ArrayList<>();
+
+ for (int y = grid.getHeight() - 1; y >= 0; y--) {
+ for (int x = 0; x < grid.getWidth(); x++) {
+ T gridElement = grid.getElement(x, y);
+ if (gridElement.getClass().isAssignableFrom(Tile.class)) {
+ Tile tile = (Tile) gridElement;
+ if (tile.getTileType() == type) {
+ objList.add(new BoardElementContainer<>(gridElement, new Position(x,y)));
+ }
+ } else if (gridElement.getClass().isAssignableFrom(Wall.class)) {
+ Wall wall = (Wall) gridElement;
+ if (wall.getWallType() == type) {
+ objList.add(new BoardElementContainer<>(gridElement, new Position(x,y)));
+ }
+ } else {
+ throw new IllegalArgumentException("Grid has unknown type.");
+ }
+ }
+ }
+ return objList;
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/inf112/fiasko/roborally/objects/BoardElementContainer.java b/src/main/java/inf112/fiasko/roborally/objects/BoardElementContainer.java
new file mode 100644
index 0000000..e120140
--- /dev/null
+++ b/src/main/java/inf112/fiasko/roborally/objects/BoardElementContainer.java
@@ -0,0 +1,38 @@
+package inf112.fiasko.roborally.objects;
+
+import inf112.fiasko.roborally.element_properties.Position;
+
+/**
+ * This class represents a type of object and its position
+ * @param The type of object
+ */
+public class BoardElementContainer {
+ K obj;
+ Position pos;
+
+ /**
+ * Initializes the BoardElementContainer
+ * @param obj The object
+ * @param pos The position
+ */
+ BoardElementContainer(K obj, Position pos) {
+ this.obj = obj;
+ this.pos = pos;
+ }
+
+ /**
+ * Gets the object
+ * @return object
+ */
+ public K getObject() {
+ return obj;
+ }
+
+ /**
+ * Gets the position
+ * @return position
+ */
+ public Position getPosition() {
+ return pos;
+ }
+}
diff --git a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java
index f56c624..d88dffa 100644
--- a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java
+++ b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java
@@ -141,14 +141,14 @@ public class RoboRallyGame implements IDrawableGame {
sleep();
switch (action) {
case MOVE_1:
- moveForward(robotID);
+ gameBoard.moveRobotForward(robotID);
break;
case MOVE_2:
- moveForward(robotID);
+ gameBoard.moveRobotForward(robotID);
moveForward(robotID);
break;
case MOVE_3:
- moveForward(robotID);
+ gameBoard.moveRobotForward(robotID);
moveForward(robotID);
moveForward(robotID);
break;