diff --git a/docs/team/referater/referat_16_03_2020.md b/docs/team/referater/referat_16_03_2020.md new file mode 100644 index 0000000..640edbb --- /dev/null +++ b/docs/team/referater/referat_16_03_2020.md @@ -0,0 +1,15 @@ +## Oppmøte +Tilstede: Steinar, Gabriel, Kristian, Torbjørn, Petter +Ikke tilstede: + +## Agenda +- Design valg + +- Brukerhistorier + +- Fordele Oppgaver + +## Møte +- Diskuterte håndtering av framtidinge møter med tanke på korona situasjonen. +- Gikk igjennom prosjekt tavlen og gikk igjennom hver oppgave der. +- Avsluttet møte ved å dele oss opp i par-programmeringsgrupper. \ No newline at end of file diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java index b28eac4..2f416bd 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Board.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Board.java @@ -178,6 +178,19 @@ public class Board { return robots.containsKey(robot); } + /** + * Updates the flag of the robot if it stands on the correct flag. + * @param robotID The RobotID of a robot + * @param flagID TileType of the flag we check + */ + public void updateFlagOnRobot(RobotID robotID, TileType flagID) { + Robot robot = robots.get(robotID); + int flagNr = flagID.getTileTypeID() % 16; + if (flagNr - 1 == robot.getLastFlagVisited()) { + robot.setLastFlagVisitedAndUpdateBackupPosition(flagNr); + } + } + /** * Checks if a potential robot move would be blocked by a wall * @param robotPosition The current position of the robot diff --git a/src/main/java/inf112/fiasko/roborally/objects/BoardElementContainer.java b/src/main/java/inf112/fiasko/roborally/objects/BoardElementContainer.java index e120140..7b253c7 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/BoardElementContainer.java +++ b/src/main/java/inf112/fiasko/roborally/objects/BoardElementContainer.java @@ -8,7 +8,7 @@ import inf112.fiasko.roborally.element_properties.Position; */ public class BoardElementContainer { K obj; - Position pos; + private Position pos; /** * Initializes the BoardElementContainer diff --git a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java index 74ae131..21e0eb5 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java +++ b/src/main/java/inf112/fiasko/roborally/objects/RoboRallyGame.java @@ -5,6 +5,7 @@ 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.utility.BoardLoaderUtil; +import javafx.geometry.Pos; import java.io.IOException; import java.util.ArrayList; @@ -204,4 +205,19 @@ public class RoboRallyGame implements IDrawableGame { } } } + + /** + * Checks all flags for robots. Tries to update the flag of the robot. + */ + private void checkAllFlags() { + List> listOfFlags = gameBoard.getPositionsOfTileOnBoard(TileType.FLAG_1, + TileType.FLAG_2, TileType.FLAG_3, TileType.FLAG_4); + for (BoardElementContainer flag:listOfFlags) { + Position flagPosition = flag.getPosition(); + if (gameBoard.hasRobotOnPosition(flagPosition)) { + RobotID robot = gameBoard.getRobotOnPosition(flagPosition); + gameBoard.updateFlagOnRobot(robot, flag.getObject().getTileType()); + } + } + } } \ No newline at end of file diff --git a/src/test/java/inf112/fiasko/roborally/objects/BoardTest.java b/src/test/java/inf112/fiasko/roborally/objects/BoardTest.java index 7d0d4bc..c155e68 100644 --- a/src/test/java/inf112/fiasko/roborally/objects/BoardTest.java +++ b/src/test/java/inf112/fiasko/roborally/objects/BoardTest.java @@ -67,6 +67,8 @@ public class BoardTest { wallGrid.setElement(2, 1, new Wall(WallType.WALL_NORMAL, Direction.SOUTH)); wallGrid.setElement(2, 2, new Wall(WallType.WALL_NORMAL, Direction.EAST)); wallGrid.setElement(1, 2, new Wall(WallType.WALL_CORNER, Direction.NORTH_EAST)); + tileGrid.setElement(3,3, new Tile(TileType.FLAG_1, Direction.NORTH)); + tileGrid.setElement(2,2, new Tile(TileType.FLAG_2, Direction.NORTH)); board = new Board(tileGrid, wallGrid, robotList); Grid tileGridAllTypes = new Grid<>(6,6); @@ -93,6 +95,23 @@ public class BoardTest { tileTypeNumberMap.put(TileType.COGWHEEL_LEFT, 1); tileTypeNumberMap.put(TileType.TILE, 5); boardWithDifferentAmountOfAllTypes = new Board(tileGridAllTypes,wallGridAllTypes,emptyRobotList); + + } + + @Test + public void flagGetsUpdatedOnRobotWithCorrectLastVisitedFlag() { + Robot testRobot = robotList.get(6); + assertEquals(0,testRobot.getLastFlagVisited()); + board.updateFlagOnRobot(RobotID.ROBOT_7, TileType.FLAG_1); + assertEquals(1,testRobot.getLastFlagVisited()); + } + + @Test + public void flagDoesNotUpdatedOnRobotWithWringLastVisitedFlag() { + Robot testRobot = robotList.get(6); + assertEquals(0,testRobot.getLastFlagVisited()); + board.updateFlagOnRobot(RobotID.ROBOT_7, TileType.FLAG_2); + assertEquals(0,testRobot.getLastFlagVisited()); } @Test