diff --git a/src/main/java/inf112/fiasko/roborally/objects/Board.java b/src/main/java/inf112/fiasko/roborally/objects/Board.java index 753b16e..ddd53d1 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Board.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Board.java @@ -443,7 +443,7 @@ public class Board { Robot robot = robots.get(robotID); int flagNr = flagID.getTileTypeID() % 16; if (flagNr - 1 == robot.getLastFlagVisited()) { - robot.setLastFlagVisitedAndUpdateBackupPosition(flagNr); + robot.setLastFlagVisited(flagNr); setHasTouchedFlagThisTurnFromRobotID(robotID, true); } } diff --git a/src/main/java/inf112/fiasko/roborally/objects/Robot.java b/src/main/java/inf112/fiasko/roborally/objects/Robot.java index 141a157..2aa753d 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Robot.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Robot.java @@ -117,12 +117,8 @@ public class Robot { * * @param currentFlag The flag the robot is standing on */ - public void setLastFlagVisitedAndUpdateBackupPosition(int currentFlag) { - if (currentFlag - 1 != this.lastFlagVisited) { - throw new IllegalArgumentException("The robot has not yet visited the previous flag!"); - } + public void setLastFlagVisited(int currentFlag) { this.lastFlagVisited = currentFlag; - this.backupPosition = currentPosition; } /** diff --git a/src/test/java/inf112/fiasko/roborally/objects/RobotTest.java b/src/test/java/inf112/fiasko/roborally/objects/RobotTest.java index 4de1186..a0d9f62 100644 --- a/src/test/java/inf112/fiasko/roborally/objects/RobotTest.java +++ b/src/test/java/inf112/fiasko/roborally/objects/RobotTest.java @@ -65,7 +65,7 @@ public class RobotTest { @Test public void testRobotGetNewFlag() { - testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag); + testRobot.setLastFlagVisited(nextFlag); assertEquals(1, testRobot.getLastFlagVisited()); } @@ -73,7 +73,7 @@ public class RobotTest { public void testRobotGetNewBackup() { Position nextFlagPosition = new Position(3, 4); testRobot.setPosition(nextFlagPosition); - testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag); + testRobot.setLastFlagVisited(nextFlag); assertEquals(nextFlagPosition, testRobot.getBackupPosition()); } }