public void checkForWinner() { //Yay! //Update the largest army and longest road stuff Player lapl = null; Player llpl = null; foreach (Player pl in playerOrder) { int arm = pl.getArmySize(); if (arm > largestArmy) { lapl = pl; largestArmy = arm; } arm = pl.getLongestRoadCount(); if (arm > longestRoad) { llpl = pl; longestRoad = arm; } pl.setLongestRoad(false); pl.setLargestArmy(false); } if (largestArmy >= 3) { if (lapl != null) { foreach (Player pl in playerOrder) { pl.setLargestArmy(false); } lapl.setLargestArmy(true); } } if (longestRoad >= 5) { if (llpl != null) { foreach (Player pl in playerOrder) { pl.setLongestRoad(false); } llpl.setLongestRoad(true); } } bool winner = false; Player winningPlayer = null; foreach (Player pl in playerOrder) { int vps = Player.calculateVictoryPoints(true, pl); if (vps >= 10) { winningPlayer = pl; winner = true; } else { pl.updateScore(); } } if (winner) { currentGameState = GameState.End; currentGameEvent.endExecution(); addEventText(winningPlayer.getName() + " has won!"); } }