From 7bd59902e2e39a71379a3a7af8d85f69436e49a9 Mon Sep 17 00:00:00 2001 From: Steinar Aalstad Lillesund Date: Mon, 16 Mar 2020 14:33:22 +0100 Subject: [PATCH 1/3] =?UTF-8?q?Referat=20fra=20m=C3=B8te.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/team/referater/referat_16_03_2020.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 docs/team/referater/referat_16_03_2020.md 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 From 31bef9fe0b758e308f2c246ef98f715f397e67c2 Mon Sep 17 00:00:00 2001 From: Steinar Aalstad Lillesund Date: Mon, 16 Mar 2020 15:52:18 +0100 Subject: [PATCH 2/3] =?UTF-8?q?Parprogrammering=20med=20tobydrama=20-=20La?= =?UTF-8?q?get=20funksjonalitet=20for=20flagg=20registrering=20Lagt=20inn?= =?UTF-8?q?=20metoder=20og=20hjelpemetoder=20for=20=C3=A5=20f=C3=A5=20til?= =?UTF-8?q?=20registrering=20av=20flagg.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inf112/fiasko/roborally/objects/Board.java | 13 +++++++++++++ .../roborally/objects/BoardElementContainer.java | 2 +- .../fiasko/roborally/objects/RoboRallyGame.java | 16 ++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java index 5ab22dc..f89c1b1 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 From c43798dfab78a314ee5b4f8c2d120a50c8621868 Mon Sep 17 00:00:00 2001 From: Steinar Aalstad Lillesund Date: Mon, 16 Mar 2020 15:52:50 +0100 Subject: [PATCH 3/3] Parprogrammering med tobydrama - Laget Tester for registrering av flagg. --- .../fiasko/roborally/objects/BoardTest.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/test/java/inf112/fiasko/roborally/objects/BoardTest.java b/src/test/java/inf112/fiasko/roborally/objects/BoardTest.java index d80bd61..f7ce301 100644 --- a/src/test/java/inf112/fiasko/roborally/objects/BoardTest.java +++ b/src/test/java/inf112/fiasko/roborally/objects/BoardTest.java @@ -61,7 +61,26 @@ 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); + + } + + @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