1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 02:42:54 +08:00

Extract combo & accuracy ratio calculation helpers

This commit is contained in:
Bartłomiej Dach 2020-12-19 19:08:29 +01:00
parent afa6a86954
commit ee33c0be93

View File

@ -201,8 +201,8 @@ namespace osu.Game.Rulesets.Scoring
private double getScore(ScoringMode mode) private double getScore(ScoringMode mode)
{ {
return GetScore(mode, maxAchievableCombo, return GetScore(mode, maxAchievableCombo,
maxBaseScore > 0 ? baseScore / maxBaseScore : 0, calculateAccuracyRatio(baseScore),
maxAchievableCombo > 0 ? (double)HighestCombo.Value / maxAchievableCombo : 1, calculateComboRatio(HighestCombo.Value),
scoreResultCounts); scoreResultCounts);
} }
@ -252,14 +252,17 @@ namespace osu.Game.Rulesets.Scoring
computedBaseScore += Judgement.ToNumericResult(pair.Key) * pair.Value; computedBaseScore += Judgement.ToNumericResult(pair.Key) * pair.Value;
} }
double accuracy = maxBaseScore > 0 ? computedBaseScore / maxBaseScore : 0; double accuracy = calculateAccuracyRatio(computedBaseScore);
double comboRatio = maxAchievableCombo > 0 ? (double)maxCombo / maxAchievableCombo : 1; double comboRatio = calculateComboRatio(maxCombo);
double score = GetScore(mode, maxAchievableCombo, accuracy, comboRatio, scoreResultCounts); double score = GetScore(mode, maxAchievableCombo, accuracy, comboRatio, scoreResultCounts);
return (score, accuracy); return (score, accuracy);
} }
private double calculateAccuracyRatio(double baseScore) => maxBaseScore > 0 ? baseScore / maxBaseScore : 0;
private double calculateComboRatio(int maxCombo) => maxAchievableCombo > 0 ? (double)maxCombo / maxAchievableCombo : 1;
private double getBonusScore(Dictionary<HitResult, int> statistics) private double getBonusScore(Dictionary<HitResult, int> statistics)
=> statistics.GetOrDefault(HitResult.SmallBonus) * Judgement.SMALL_BONUS_SCORE => statistics.GetOrDefault(HitResult.SmallBonus) * Judgement.SMALL_BONUS_SCORE
+ statistics.GetOrDefault(HitResult.LargeBonus) * Judgement.LARGE_BONUS_SCORE; + statistics.GetOrDefault(HitResult.LargeBonus) * Judgement.LARGE_BONUS_SCORE;