mirror of
https://github.com/ppy/osu.git
synced 2025-02-01 00:39:11 +08:00
Introduce method for computing maximum achievable combo properly
This commit is contained in:
parent
c5cc7eec79
commit
d36f32a9c9
@ -134,35 +134,9 @@ namespace osu.Game.Scoring
|
|||||||
if (string.IsNullOrEmpty(score.BeatmapInfo.MD5Hash))
|
if (string.IsNullOrEmpty(score.BeatmapInfo.MD5Hash))
|
||||||
return score.TotalScore;
|
return score.TotalScore;
|
||||||
|
|
||||||
int beatmapMaxCombo;
|
int? beatmapMaxCombo = await GetBeatmapMaximumComboAsync(score, cancellationToken).ConfigureAwait(false);
|
||||||
|
if (beatmapMaxCombo == null)
|
||||||
if (score.IsLegacyScore)
|
return score.TotalScore;
|
||||||
{
|
|
||||||
// This score is guaranteed to be an osu!stable score.
|
|
||||||
// The combo must be determined through either the beatmap's max combo value or the difficulty calculator, as lazer's scoring has changed and the score statistics cannot be used.
|
|
||||||
if (score.BeatmapInfo.MaxCombo != null)
|
|
||||||
beatmapMaxCombo = score.BeatmapInfo.MaxCombo.Value;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (difficulties == null)
|
|
||||||
return score.TotalScore;
|
|
||||||
|
|
||||||
// We can compute the max combo locally after the async beatmap difficulty computation.
|
|
||||||
var difficulty = await difficulties().GetDifficultyAsync(score.BeatmapInfo, score.Ruleset, score.Mods, cancellationToken).ConfigureAwait(false);
|
|
||||||
|
|
||||||
// Something failed during difficulty calculation. Fall back to provided score.
|
|
||||||
if (difficulty == null)
|
|
||||||
return score.TotalScore;
|
|
||||||
|
|
||||||
beatmapMaxCombo = difficulty.Value.MaxCombo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// This is guaranteed to be a non-legacy score.
|
|
||||||
// The combo must be determined through the score's statistics, as both the beatmap's max combo and the difficulty calculator will provide osu!stable combo values.
|
|
||||||
beatmapMaxCombo = Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetValueOrDefault(r)).Sum();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (beatmapMaxCombo == 0)
|
if (beatmapMaxCombo == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -171,7 +145,35 @@ namespace osu.Game.Scoring
|
|||||||
var scoreProcessor = ruleset.CreateScoreProcessor();
|
var scoreProcessor = ruleset.CreateScoreProcessor();
|
||||||
scoreProcessor.Mods.Value = score.Mods;
|
scoreProcessor.Mods.Value = score.Mods;
|
||||||
|
|
||||||
return (long)Math.Round(scoreProcessor.ComputeFinalLegacyScore(mode, score, beatmapMaxCombo));
|
return (long)Math.Round(scoreProcessor.ComputeFinalLegacyScore(mode, score, beatmapMaxCombo.Value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the maximum achievable combo on the beatmap of the provided score.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="score">The <see cref="ScoreInfo"/> to compute the maximum achievable combo for.</param>
|
||||||
|
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to cancel the process.</param>
|
||||||
|
/// <returns>The maximum achievable combo.</returns>
|
||||||
|
public async Task<int?> GetBeatmapMaximumComboAsync([NotNull] ScoreInfo score, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
if (score.IsLegacyScore)
|
||||||
|
{
|
||||||
|
// This score is guaranteed to be an osu!stable score.
|
||||||
|
// The combo must be determined through either the beatmap's max combo value or the difficulty calculator, as lazer's scoring has changed and the score statistics cannot be used.
|
||||||
|
if (score.BeatmapInfo.MaxCombo != null)
|
||||||
|
return score.BeatmapInfo.MaxCombo.Value;
|
||||||
|
|
||||||
|
if (difficulties == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// We can compute the max combo locally after the async beatmap difficulty computation.
|
||||||
|
var difficulty = await difficulties().GetDifficultyAsync(score.BeatmapInfo, score.Ruleset, score.Mods, cancellationToken).ConfigureAwait(false);
|
||||||
|
return difficulty?.MaxCombo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is guaranteed to be a non-legacy score.
|
||||||
|
// The combo must be determined through the score's statistics, as both the beatmap's max combo and the difficulty calculator will provide osu!stable combo values.
|
||||||
|
return Enum.GetValues(typeof(HitResult)).OfType<HitResult>().Where(r => r.AffectsCombo()).Select(r => score.Statistics.GetValueOrDefault(r)).Sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user