private void ClearAllData(IGameRankingDataAccess DAL) { DAL.ClearAllData(); DAL.SubmitGameListChanges(); DAL.SubmitPlayerListChanges(); DAL.SubmitTeamListChanges(); DAL.SubmitmatchListChanges(); DAL.SubmitRankingListChanges(); }
private void ClearAllData(IGameRankingDataAccess DAL) { DAL.ClearAllData(); DAL.SubmitGameListChanges(); DAL.SubmitPlayerListChanges(); DAL.SubmitTeamListChanges(); DAL.SubmitmatchListChanges(); DAL.SubmitRankingListChanges(); }
/// <summary> /// Updates all ranking scores /// </summary> private void UpdateScores() { backend.RankingList.Clear(); backend.SubmitRankingListChanges(); // update points foreach (MatchType match in backend.MatchList) { if (match is SoloMatch) { SoloMatch soloMatch = (SoloMatch)match; if (soloMatch.Players.Count < 1) { continue; } int maxPoints = soloMatch.Players.Count + 1; List <int> uniquePoints = GenerateUniqueOrdered(soloMatch.Scores); for (int i = 0; i < uniquePoints.Count; i++) { if (i >= (uniquePoints.Count - 1)) { maxPoints = 0; // no point for player for (int j = 0; j < soloMatch.Players.Count; j++) { if (uniquePoints[i] == soloMatch.Scores[j]) { AddPoints(soloMatch.GameID, soloMatch.Players[j], soloMatch.Category, maxPoints); } } } else if (i == 0) { // max points for (int j = 0; j < soloMatch.Players.Count; j++) { if (uniquePoints[i] == soloMatch.Scores[j]) { AddPoints(soloMatch.GameID, soloMatch.Players[j], soloMatch.Category, maxPoints); } } maxPoints -= 2; } else { for (int j = 0; j < soloMatch.Players.Count; j++) { if (uniquePoints[i] == soloMatch.Scores[j]) { AddPoints(soloMatch.GameID, soloMatch.Players[j], soloMatch.Category, maxPoints); } } maxPoints--; } } } else if (match is TeamMatch) { TeamMatch teamMatch = (TeamMatch)match; if (teamMatch.Teams.Count < 1) { continue; } int maxPoints = teamMatch.Teams.Count + 1; List <int> uniquePoints = GenerateUniqueOrdered(teamMatch.Scores); for (int i = 0; i < uniquePoints.Count; i++) { if (i >= (uniquePoints.Count - 1)) { maxPoints = 0; // no point for player for (int j = 0; j < teamMatch.Teams.Count; j++) { if (uniquePoints[i] == teamMatch.Scores[j]) { foreach (PlayerType player in teamMatch.Teams[j].Members) { AddPoints(teamMatch.GameID, player, teamMatch.Category, maxPoints); } } } } else if (i == 0) { // max points for (int j = 0; j < teamMatch.Teams.Count; j++) { if (uniquePoints[i] == teamMatch.Scores[j]) { foreach (PlayerType player in teamMatch.Teams[j].Members) { AddPoints(teamMatch.GameID, player, teamMatch.Category, maxPoints); } } } maxPoints -= 2; } else { for (int j = 0; j < teamMatch.Teams.Count; j++) { if (uniquePoints[i] == teamMatch.Scores[j]) { foreach (PlayerType player in teamMatch.Teams[j].Members) { AddPoints(teamMatch.GameID, player, teamMatch.Category, maxPoints); } } } maxPoints--; } } } } }