1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:02:53 +08:00

Merge pull request #26557 from peppy/fix-silver-s-ss

Fix silver S/SS not being awarded correctly
This commit is contained in:
Bartłomiej Dach 2024-01-16 10:03:20 +01:00 committed by GitHub
commit 805a9b56ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 11 deletions

View File

@ -18,10 +18,12 @@ using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Judgements;
using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko;
using osu.Game.Rulesets.UI;
using osu.Game.Scoring;
using osu.Game.Scoring.Legacy;
using osu.Game.Tests.Beatmaps;
@ -385,6 +387,42 @@ namespace osu.Game.Tests.Rulesets.Scoring
Assert.That(scoreProcessor.Accuracy.Value, Is.Not.EqualTo(1));
}
[Test]
public void TestNormalGrades()
{
scoreProcessor.ApplyBeatmap(new Beatmap());
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.X));
scoreProcessor.Accuracy.Value = 0.99f;
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.S));
}
[Test]
public void TestSilverGrades()
{
scoreProcessor.ApplyBeatmap(new Beatmap());
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.X));
scoreProcessor.Mods.Value = new[] { new OsuModHidden() };
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.XH));
scoreProcessor.Accuracy.Value = 0.99f;
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.SH));
}
[Test]
public void TestSilverGradesModsAppliedFirst()
{
scoreProcessor.Mods.Value = new[] { new OsuModHidden() };
scoreProcessor.ApplyBeatmap(new Beatmap());
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.XH));
scoreProcessor.Accuracy.Value = 0.99f;
Assert.That(scoreProcessor.Rank.Value, Is.EqualTo(ScoreRank.SH));
}
private class TestJudgement : Judgement
{
public override HitResult MaxResult { get; }

View File

@ -186,16 +186,7 @@ namespace osu.Game.Rulesets.Scoring
Ruleset = ruleset;
Combo.ValueChanged += combo => HighestCombo.Value = Math.Max(HighestCombo.Value, combo.NewValue);
Accuracy.ValueChanged += accuracy =>
{
// Once failed, we shouldn't update the rank anymore.
if (rank.Value == ScoreRank.F)
return;
rank.Value = RankFromAccuracy(accuracy.NewValue);
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
rank.Value = mod.AdjustRank(Rank.Value, accuracy.NewValue);
};
Accuracy.ValueChanged += _ => updateRank();
Mods.ValueChanged += mods =>
{
@ -205,6 +196,7 @@ namespace osu.Game.Rulesets.Scoring
scoreMultiplier *= m.ScoreMultiplier;
updateScore();
updateRank();
};
}
@ -372,6 +364,17 @@ namespace osu.Game.Rulesets.Scoring
TotalScore.Value = (long)Math.Round(ComputeTotalScore(comboProgress, accuracyProcess, currentBonusPortion) * scoreMultiplier);
}
private void updateRank()
{
// Once failed, we shouldn't update the rank anymore.
if (rank.Value == ScoreRank.F)
return;
rank.Value = RankFromAccuracy(Accuracy.Value);
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
rank.Value = mod.AdjustRank(Rank.Value, Accuracy.Value);
}
protected virtual double ComputeTotalScore(double comboProgress, double accuracyProgress, double bonusPortion)
{
return 500000 * Accuracy.Value * comboProgress +
@ -417,8 +420,8 @@ namespace osu.Game.Rulesets.Scoring
TotalScore.Value = 0;
Accuracy.Value = 1;
Combo.Value = 0;
rank.Value = ScoreRank.X;
HighestCombo.Value = 0;
updateRank();
}
/// <summary>