removed the the update respawn location of the robot from the function

This commit is contained in:
Tobydrama 2020-04-20 18:21:05 +02:00
parent a886b5e23d
commit c137208ce5
3 changed files with 4 additions and 8 deletions

View File

@ -443,7 +443,7 @@ public class Board {
Robot robot = robots.get(robotID); Robot robot = robots.get(robotID);
int flagNr = flagID.getTileTypeID() % 16; int flagNr = flagID.getTileTypeID() % 16;
if (flagNr - 1 == robot.getLastFlagVisited()) { if (flagNr - 1 == robot.getLastFlagVisited()) {
robot.setLastFlagVisitedAndUpdateBackupPosition(flagNr); robot.setLastFlagVisited(flagNr);
setHasTouchedFlagThisTurnFromRobotID(robotID, true); setHasTouchedFlagThisTurnFromRobotID(robotID, true);
} }
} }

View File

@ -117,12 +117,8 @@ public class Robot {
* *
* @param currentFlag The flag the robot is standing on * @param currentFlag The flag the robot is standing on
*/ */
public void setLastFlagVisitedAndUpdateBackupPosition(int currentFlag) { public void setLastFlagVisited(int currentFlag) {
if (currentFlag - 1 != this.lastFlagVisited) {
throw new IllegalArgumentException("The robot has not yet visited the previous flag!");
}
this.lastFlagVisited = currentFlag; this.lastFlagVisited = currentFlag;
this.backupPosition = currentPosition;
} }
/** /**

View File

@ -65,7 +65,7 @@ public class RobotTest {
@Test @Test
public void testRobotGetNewFlag() { public void testRobotGetNewFlag() {
testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag); testRobot.setLastFlagVisited(nextFlag);
assertEquals(1, testRobot.getLastFlagVisited()); assertEquals(1, testRobot.getLastFlagVisited());
} }
@ -73,7 +73,7 @@ public class RobotTest {
public void testRobotGetNewBackup() { public void testRobotGetNewBackup() {
Position nextFlagPosition = new Position(3, 4); Position nextFlagPosition = new Position(3, 4);
testRobot.setPosition(nextFlagPosition); testRobot.setPosition(nextFlagPosition);
testRobot.setLastFlagVisitedAndUpdateBackupPosition(nextFlag); testRobot.setLastFlagVisited(nextFlag);
assertEquals(nextFlagPosition, testRobot.getBackupPosition()); assertEquals(nextFlagPosition, testRobot.getBackupPosition());
} }
} }