Lager felt for winningPlayerName og setter og getter til den

Co-Authored-By: torlunjen <torlunjen@users.noreply.github.com>
This commit is contained in:
GabrielMagnus 2020-04-14 15:21:48 +02:00
parent 48afdfd9f9
commit ff2f8a849e

View File

@ -30,11 +30,21 @@ public class RoboRallyGame implements IDrawableGame {
private final boolean host; private final boolean host;
private Deck<ProgrammingCard> mainDeck; private Deck<ProgrammingCard> mainDeck;
private GameState gameState = GameState.INITIAL_SETUP; private GameState gameState = GameState.INITIAL_SETUP;
private String winningPlayerName;
public String getWinningPlayerName() {
return winningPlayerName;
}
public void setWinningPlayerName(String winningPlayerName) {
this.winningPlayerName = winningPlayerName;
}
/** /**
* Returns the gameState of the game * Returns the gameState of the game
* @return the gameState of the game * @return the gameState of the game
*/ */
@Override
public GameState getGameState(){ public GameState getGameState(){
return gameState; return gameState;
} }
@ -43,6 +53,7 @@ public class RoboRallyGame implements IDrawableGame {
* Sets the gameState of the game * Sets the gameState of the game
* @param gameState the gameState * @param gameState the gameState
*/ */
@Override
public void setGameState(GameState gameState) { public void setGameState(GameState gameState) {
this.gameState = gameState; this.gameState = gameState;
} }
@ -499,14 +510,13 @@ 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())) { if (victoryCheck(robot.getLastFlagVisited(), listOfFlags.size())) {
Player winningPlayer;
for (Player player : playerList) { for (Player player : playerList) {
if (player.getRobotID() != robotID) { if (player.getRobotID() != robotID) {
continue; continue;
} }
winningPlayer = player; setWinningPlayerName(player.getName());
setGameState(GameState.GAME_IS_WON);
} }
//TODO: Make win screen announcing the winning player
} }
} }
} }