mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Update RoboRallyGame.java
Legger til funksjonalitet for at en robot bare kan registrere besøk på ett flagg hver runde. Co-Authored-By: gabrielmagnus <gabrielmagnus@users.noreply.github.com>
This commit is contained in:
parent
9f843b8db6
commit
af1daebd15
@ -216,6 +216,16 @@ public class RoboRallyGame implements IDrawableGame {
|
||||
// TODO: If this player is in power down, ask if it shall continue
|
||||
// Respawn dead robots, as long as they have more lives left
|
||||
respawnRobots();
|
||||
resetHasTouchedFlagThisTurnForAllRobots();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -462,8 +472,14 @@ public class RoboRallyGame implements IDrawableGame {
|
||||
for (BoardElementContainer<Tile> flag:listOfFlags) {
|
||||
Position flagPosition = flag.getPosition();
|
||||
if (gameBoard.hasRobotOnPosition(flagPosition)) {
|
||||
RobotID robot = gameBoard.getRobotOnPosition(flagPosition);
|
||||
gameBoard.updateFlagOnRobot(robot, flag.getElement().getTileType());
|
||||
RobotID robotID = gameBoard.getRobotOnPosition(flagPosition);
|
||||
for (Robot robot : gameBoard.getAliveRobots()) {
|
||||
if (robot.getRobotId() != robotID || robot.isHasTouchedFlagThisTurn()) {
|
||||
continue;
|
||||
}
|
||||
gameBoard.updateFlagOnRobot(robotID, flag.getElement().getTileType());
|
||||
robot.setHasTouchedFlagThisTurn(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user