private static PlayerScore CreatePlayerScoreFromReader(IDataReader reader) { var playerStats = new PlayerScore(); playerStats.id = (int)reader["playerId"]; playerStats.wins = (int)reader["wins"]; playerStats.lose = (int)reader["lose"]; playerStats.draw = (int)reader["draw"]; playerStats.win_frames = (int)reader["win_frames"]; playerStats.lose_frames = (int)reader["lose_frames"]; playerStats.groupId = (int)reader["GroupId"]; return(playerStats); }
private static bool ScoreIsHigherThanCurrentBest(PlayerScore playerScore, Dictionary <int, PlayerScore> highestGroupScores) { return(playerScore.score > highestGroupScores[playerScore.groupId].score); }
private static void SetNewHighestScore(Dictionary <int, PlayerScore> highestGroupScores, PlayerScore playerScore) { if (ScoreIsHigherThanCurrentBest(playerScore, highestGroupScores)) { highestGroupScores[playerScore.groupId] = playerScore; } }
private static void UpdateHighestScore(Dictionary <int, PlayerScore> highestGroupScores, PlayerScore playerScore) { if (highestGroupScores.ContainsKey(playerScore.groupId)) { SetNewHighestScore(highestGroupScores, playerScore); } else { highestGroupScores.Add(playerScore.groupId, playerScore); } }
private static bool PlayersAreInTheSameGroup(PlayerScore player1, PlayerScore player2) { return(player1.groupId == player2.groupId); }