Update RoboRallyGame.java

Laget victory check og finner vinneren

Co-Authored-By: gabrielmagnus <gabrielmagnus@users.noreply.github.com>
This commit is contained in:
torlunjen 2020-04-09 20:39:04 +02:00
parent af1daebd15
commit a1e3a80a68

View File

@ -5,6 +5,7 @@ import inf112.fiasko.roborally.element_properties.Direction;
import inf112.fiasko.roborally.element_properties.Position; import inf112.fiasko.roborally.element_properties.Position;
import inf112.fiasko.roborally.element_properties.RobotID; import inf112.fiasko.roborally.element_properties.RobotID;
import inf112.fiasko.roborally.element_properties.TileType; import inf112.fiasko.roborally.element_properties.TileType;
import inf112.fiasko.roborally.game_wrapper.screens.StartMenuScreen;
import inf112.fiasko.roborally.utility.BoardLoaderUtil; import inf112.fiasko.roborally.utility.BoardLoaderUtil;
import inf112.fiasko.roborally.utility.DeckLoaderUtil; import inf112.fiasko.roborally.utility.DeckLoaderUtil;
@ -316,6 +317,7 @@ public class RoboRallyGame implements IDrawableGame {
fireAllLasers(); fireAllLasers();
checkAllFlags(); checkAllFlags();
} }
/** /**
@ -479,11 +481,24 @@ public class RoboRallyGame implements IDrawableGame {
} }
gameBoard.updateFlagOnRobot(robotID, flag.getElement().getTileType()); gameBoard.updateFlagOnRobot(robotID, flag.getElement().getTileType());
robot.setHasTouchedFlagThisTurn(true); robot.setHasTouchedFlagThisTurn(true);
if (victoryCheck(robot.getLastFlagVisited(), listOfFlags.size())) {
Player winningPlayer;
for (Player player : playerList) {
if (player.getRobotID() != robotID) {
continue;
}
winningPlayer = player;
}
//TODO: Make win screen announcing the winning player
}
} }
} }
} }
} }
private boolean victoryCheck(int lastFlagVisited, int lastFlag) {
return (lastFlagVisited == lastFlag);
}
/** /**
* Fires all lasers on the game board * Fires all lasers on the game board
*/ */