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);
int flagNr = flagID.getTileTypeID() % 16;
if (flagNr - 1 == robot.getLastFlagVisited()) {
robot.setLastFlagVisitedAndUpdateBackupPosition(flagNr);
robot.setLastFlagVisited(flagNr);
setHasTouchedFlagThisTurnFromRobotID(robotID, true);
}
}

View File

@ -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;
}
/**

View File

@ -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());
}
}