From 566346476c00e62725f830b876ba4ee0a4fb0dea Mon Sep 17 00:00:00 2001 From: Tobydrama Date: Mon, 30 Mar 2020 18:32:55 +0200 Subject: [PATCH] la til en del funksjoner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit la til repairAllRobotsOnReparerTiles som fikers en skade for alle roboter som står på repair tiles la til respawnRobots som respawner alle døde roboter la til en host variabel som blir initialisert til false --- .../roborally/objects/RoboRallyGame.java | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java index 928c4be..5040552 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java +++ b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java @@ -25,12 +25,13 @@ public class RoboRallyGame implements IDrawableGame { private List> conveyorBelts; private List> fastConveyorBelts; private List playerList; - + private final boolean host; /** * Instantiates a new robo rally game * @param debug Whether to start the game in debugging mode */ public RoboRallyGame(boolean debug) { + this.host=false; if (debug) { initializeDebugMode(); } else { @@ -42,6 +43,7 @@ public class RoboRallyGame implements IDrawableGame { * Instantiates a new robo rally game */ public RoboRallyGame() { + this.host=false; initializeGame(); } @@ -191,6 +193,7 @@ public class RoboRallyGame implements IDrawableGame { runPhase(3); runPhase(4); runPhase(5); + respawnRobots(); } /** @@ -402,4 +405,27 @@ public class RoboRallyGame implements IDrawableGame { makeMove(robot, card.getAction()); } } + + /** + * Respawn all the dead robots with more lives and places them on the game board + */ + private void respawnRobots(){ + gameBoard.respawnRobots(); + } + + /** + * repair all robots standing on a reparer tile + */ + private void repairAllRobotsOnReparerTiles(){ + List> listOfRepareTiles = gameBoard.getPositionsOfTileOnBoard(TileType.FLAG_1, + TileType.FLAG_2, TileType.FLAG_3, TileType.FLAG_4, TileType.WRENCH, TileType.WRENCH_AND_HAMMER); + for (BoardElementContainer repareTile:listOfRepareTiles) { + Position robotOnTilePosition = repareTile.getPosition(); + if (!gameBoard.hasRobotOnPosition(robotOnTilePosition)){ + continue; + } + gameBoard.repairRobotOnTile(gameBoard.getRobotOnPosition(robotOnTilePosition)); + } + } + } \ No newline at end of file