private void SetWinnerToHighestPointEarner() { // If all of the PlayerSupervisors have equal points, report a tie. if (Array.TrueForAll(playerSupervisors, ps => ps.GetPoints() == playerSupervisors[0].GetPoints())) { gameData.gameResult = $"It's a tie!"; } // Otherwise, report the highest scoring player's name. else { PlayerSupervisor winner = playerSupervisors[0]; for (int i = 1; i < playerSupervisors.Length; i++) { if (playerSupervisors[i].GetPoints() > winner.GetPoints()) { winner = playerSupervisors[i]; } } if (winner.GetPlayerType() == PlayerType.Human) { gameData.gameResult = $"You Win!"; } else { gameData.gameResult = $"{winner.GetName()} Wins!"; } } }
private void SetWinner(PlayerSupervisor winner) { if (winner.GetPlayerType() == PlayerType.Human) { gameData.gameResult = $"You Win!"; } else { gameData.gameResult = $"{winner.GetName()} Wins!"; } }