Fikser noen bugs rundt flagg og diverse Closes #75

Fikser noen tiles i Dizzy Dash som var feil vei
Fikser resetting av hasTouchedFlagThisTurn
Fikser at RoboRallyGame sin setProgram ikke godtar et tomt program
Utvider flaggtesten til å inkludere alle flagg
This commit is contained in:
2020-04-24 19:10:30 +02:00
parent 4f47e7e809
commit 35fccac794
5 changed files with 50 additions and 24 deletions

View File

@@ -890,7 +890,13 @@ public class Board {
* @param hasTouched If the robot has touched a flag this turn
*/
public void setHasTouchedFlagThisTurn(RobotID robotID, boolean hasTouched) {
robots.get(robotID).setHasTouchedFlagThisTurn(hasTouched);
Robot aliveRobot = robots.get(robotID);
Robot deadRobot = getRobotFromDeadRobots(robotID);
if (aliveRobot != null) {
aliveRobot.setHasTouchedFlagThisTurn(hasTouched);
} else if (deadRobot != null) {
deadRobot.setHasTouchedFlagThisTurn(hasTouched);
}
}
/**

View File

@@ -131,7 +131,7 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
@Override
public void setProgram(List<ProgrammingCard> program) {
if (program.size() != 5) {
if (program.size() != 5 && program.size() != 0) {
throw new IllegalArgumentException("Invalid program chosen.");
}
this.program = program;
@@ -307,8 +307,8 @@ public class RoboRallyGame implements DrawableGame, InteractableGame {
* Resets the boolean for if the robot has touched a flag this turn, to set up the next turn.
*/
private void resetHasTouchedFlagThisTurnForAllRobots() {
for (Robot robot : gameBoard.getAliveRobots()) {
robot.setHasTouchedFlagThisTurn(false);
for (RobotID robotID : RobotID.values()) {
gameBoard.setHasTouchedFlagThisTurn(robotID, false);
}
}