mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Fix maps with only bonus score having NaN scores
This commit is contained in:
parent
58186fc476
commit
447fd07b4e
@ -28,6 +28,20 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(0.0));
|
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(0.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestOnlyBonusScore()
|
||||||
|
{
|
||||||
|
var beatmap = new Beatmap<TestBonusHitObject> { HitObjects = { new TestBonusHitObject() } };
|
||||||
|
|
||||||
|
var scoreProcessor = new ScoreProcessor();
|
||||||
|
scoreProcessor.ApplyBeatmap(beatmap);
|
||||||
|
|
||||||
|
// Apply a judgement
|
||||||
|
scoreProcessor.ApplyResult(new JudgementResult(new TestBonusHitObject(), new TestBonusJudgement()) { Type = HitResult.Perfect });
|
||||||
|
|
||||||
|
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(100));
|
||||||
|
}
|
||||||
|
|
||||||
private class TestHitObject : HitObject
|
private class TestHitObject : HitObject
|
||||||
{
|
{
|
||||||
public override Judgement CreateJudgement() => new TestJudgement();
|
public override Judgement CreateJudgement() => new TestJudgement();
|
||||||
@ -37,5 +51,17 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
{
|
{
|
||||||
protected override int NumericResultFor(HitResult result) => 100;
|
protected override int NumericResultFor(HitResult result) => 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TestBonusHitObject : HitObject
|
||||||
|
{
|
||||||
|
public override Judgement CreateJudgement() => new TestBonusJudgement();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestBonusJudgement : Judgement
|
||||||
|
{
|
||||||
|
public override bool AffectsCombo => false;
|
||||||
|
|
||||||
|
protected override int NumericResultFor(HitResult result) => 100;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,7 +202,13 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
TotalScore.Value = getScore(Mode.Value);
|
TotalScore.Value = getScore(Mode.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getScore(ScoringMode mode) => GetScore(mode, maxHighestCombo, baseScore / maxBaseScore, (double)HighestCombo.Value / maxHighestCombo, bonusScore);
|
private double getScore(ScoringMode mode)
|
||||||
|
{
|
||||||
|
return GetScore(mode, maxHighestCombo,
|
||||||
|
maxBaseScore > 0 ? baseScore / maxBaseScore : 0,
|
||||||
|
maxHighestCombo > 0 ? (double)HighestCombo.Value / maxHighestCombo : 0,
|
||||||
|
bonusScore);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Computes the total score.
|
/// Computes the total score.
|
||||||
|
Loading…
Reference in New Issue
Block a user