/// <summary> /// Returns the highest rank achieved for a level and a given list of difficulties. /// NOTE: this method obtains the rank by performing a calculation on the set score and assumes that no modifiers were used. /// </summary> /// <param name="level">The level to search through.</param> /// <param name="difficulties">A list of BeatmapDifficulties to search through. Use null to search through all difficulties.</param> /// <param name="characteristics">A list of characteristics to search through. Each characteristic is represented by its serialized string. /// Use null to search through all characteristics.</param> /// <param name="playerName">The name of the player on the local leaderboards (optional).</param> /// <returns>The highest RankModel.Rank enum found for the selected difficulties, or null if the level has not yet been completed.</returns> public RankModel.Rank?GetHighestRankForLevel(BeatmapDetails level, IEnumerable <BeatmapDifficulty> difficulties = null, IEnumerable <string> characteristics = null, string playerName = null) { if (difficulties == null) { difficulties = AllDifficulties; } if (characteristics == null) { characteristics = AllCharacteristicStrings; } // get any level duplicates List <string> duplicateLevelIDs = GetActualLevelIDs(level.LevelID); StringBuilder sb = new StringBuilder(); RankModel.Rank?highestRank = null; foreach (var levID in duplicateLevelIDs) { foreach (var characteristic in AllCharacteristicStrings) { var simplifiedChar = level.DifficultyBeatmapSets.FirstOrDefault(x => x.CharacteristicName == characteristic || (characteristic == "" && x.CharacteristicName == "Standard")); if (simplifiedChar == null) { continue; } foreach (var difficulty in difficulties) { var simplifiedDiff = simplifiedChar.DifficultyBeatmaps.FirstOrDefault(x => x.Difficulty == difficulty); if (simplifiedDiff == null) { continue; } sb.Clear(); sb.Append(levID); sb.Append(characteristic); sb.Append(difficulty.ToString()); string leaderboardID = sb.ToString(); var scores = _localLeaderboardsModel.GetScores(leaderboardID, LocalLeaderboardsModel.LeaderboardType.AllTime); int maxRawScore = ScoreModel.MaxRawScoreForNumberOfNotes(simplifiedDiff.NotesCount); if (scores != null) { var validEntries = scores.Where(x => x._score != 0 && (x._playerName == playerName || playerName == null)); if (validEntries.Count() > 0) { var validRanks = validEntries.Select(x => RankModel.GetRankForScore(x._score, x._score, maxRawScore, maxRawScore)); highestRank = (RankModel.Rank)Math.Max((int)(highestRank ?? RankModel.Rank.E), (int)validRanks.Max()); } } } } } return(highestRank); }
public void UpdateCurrentMaxScore() { GameStatus gameStatus = statusManager.gameStatus; int currentMaxScoreBeforeMultiplier = ScoreModel.MaxRawScoreForNumberOfNotes(gameStatus.passedNotes); gameStatus.currentMaxScore = gameplayModifiersSO.MaxModifiedScoreForMaxRawScore(currentMaxScoreBeforeMultiplier, gameplayModifiers, gameplayModifiersSO, gameEnergyCounter.energy); RankModel.Rank rank = RankModel.GetRankForScore(gameStatus.rawScore, gameStatus.score, currentMaxScoreBeforeMultiplier, gameStatus.currentMaxScore); gameStatus.rank = RankModel.GetRankName(rank); }
private void OnScoreDidChange(int scoreBeforeMultiplier) { Data.score = ScoreController.GetScoreForGameplayModifiersScoreMultiplier(scoreBeforeMultiplier, Data.modifierMultiplier); int currentMaxScoreBeforeMultiplier = ScoreController.MaxScoreForNumberOfNotes(Data.passedNotes); Data.currentMaxScore = ScoreController.GetScoreForGameplayModifiersScoreMultiplier(currentMaxScoreBeforeMultiplier, Data.modifierMultiplier); RankModel.Rank rank = RankModel.GetRankForScore(scoreBeforeMultiplier, Data.score, currentMaxScoreBeforeMultiplier, Data.currentMaxScore); Data.rank = RankModel.GetRankName(rank); Data.StatusChange(ChangedProperties.Performance, "scoreChanged"); }
public void OnScoreDidChange(int scoreBeforeMultiplier, int scoreAfterMultiplier) { GameStatus gameStatus = statusManager.gameStatus; gameStatus.score = scoreAfterMultiplier; int currentMaxScoreBeforeMultiplier = ScoreController.MaxRawScoreForNumberOfNotes(gameStatus.passedNotes); gameStatus.currentMaxScore = ScoreController.MaxModifiedScoreForMaxRawScore(currentMaxScoreBeforeMultiplier, gameplayModifiers, gameplayModifiersSO); RankModel.Rank rank = RankModel.GetRankForScore(scoreBeforeMultiplier, gameStatus.score, currentMaxScoreBeforeMultiplier, gameStatus.currentMaxScore); gameStatus.rank = RankModel.GetRankName(rank); statusManager.EmitStatusUpdate(ChangedProperties.Performance, "scoreChanged"); }
public void OnScoreDidChange(int scoreBeforeMultiplier) { try { gameStatus.score = ScoreController.GetScoreForGameplayModifiersScoreMultiplier(scoreBeforeMultiplier, gameStatus.modifierMultiplier); int currentMaxScoreBeforeMultiplier = ScoreController.MaxScoreForNumberOfNotes(gameStatus.passedNotes); gameStatus.currentMaxScore = ScoreController.GetScoreForGameplayModifiersScoreMultiplier(currentMaxScoreBeforeMultiplier, gameStatus.modifierMultiplier); RankModel.Rank rank = RankModel.GetRankForScore(scoreBeforeMultiplier, gameStatus.score, currentMaxScoreBeforeMultiplier, gameStatus.currentMaxScore); gameStatus.rank = RankModel.GetRankName(rank); }catch (Exception ex) { Plugin.Log("EXception in score change: " + ex); } }