mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 12:17:46 +08:00
Add method to ScoreProcessor to calculate score and accuracy from statistics
This commit is contained in:
parent
fb795f6bfd
commit
2954218897
@ -68,7 +68,12 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
private readonly double comboPortion;
|
private readonly double comboPortion;
|
||||||
|
|
||||||
private int maxAchievableCombo;
|
private int maxAchievableCombo;
|
||||||
private double maxBaseScore;
|
|
||||||
|
/// <summary>
|
||||||
|
/// The maximum achievable base score.
|
||||||
|
/// </summary>
|
||||||
|
public double MaxBaseScore { get; private set; }
|
||||||
|
|
||||||
private double rollingMaxBaseScore;
|
private double rollingMaxBaseScore;
|
||||||
private double baseScore;
|
private double baseScore;
|
||||||
|
|
||||||
@ -196,7 +201,7 @@ 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,
|
MaxBaseScore > 0 ? baseScore / MaxBaseScore : 0,
|
||||||
maxAchievableCombo > 0 ? (double)HighestCombo.Value / maxAchievableCombo : 1,
|
maxAchievableCombo > 0 ? (double)HighestCombo.Value / maxAchievableCombo : 1,
|
||||||
scoreResultCounts);
|
scoreResultCounts);
|
||||||
}
|
}
|
||||||
@ -227,6 +232,34 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Given a minimal set of inputs, return the computed score and accuracy for the tracked beatmap / mods combination.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mode">The <see cref="ScoringMode"/> to compute the total score in.</param>
|
||||||
|
/// <param name="maxCombo">The maximum combo achievable in the beatmap.</param>
|
||||||
|
/// <param name="statistics">Statistics to be used for calculating accuracy, bonus score, etc.</param>
|
||||||
|
/// <returns>The computed score and accuracy for provided inputs.</returns>
|
||||||
|
public (double score, double accuracy) GetScoreAndAccuracy(ScoringMode mode, int maxCombo, Dictionary<HitResult, int> statistics)
|
||||||
|
{
|
||||||
|
// calculate base score from statistics pairs
|
||||||
|
int computedBaseScore = 0;
|
||||||
|
|
||||||
|
foreach (var pair in statistics)
|
||||||
|
{
|
||||||
|
if (!pair.Key.AffectsAccuracy())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
computedBaseScore += Judgement.ToNumericResult(pair.Key) * pair.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
double accuracy = MaxBaseScore > 0 ? computedBaseScore / MaxBaseScore : 0;
|
||||||
|
double comboRatio = maxAchievableCombo > 0 ? (double)HighestCombo.Value / maxAchievableCombo : 1;
|
||||||
|
|
||||||
|
double score = GetScore(mode, maxAchievableCombo, accuracy, comboRatio, scoreResultCounts);
|
||||||
|
|
||||||
|
return (score, accuracy);
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -266,7 +299,7 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
if (storeResults)
|
if (storeResults)
|
||||||
{
|
{
|
||||||
maxAchievableCombo = HighestCombo.Value;
|
maxAchievableCombo = HighestCombo.Value;
|
||||||
maxBaseScore = baseScore;
|
MaxBaseScore = baseScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
baseScore = 0;
|
baseScore = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user