mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 13:22:55 +08:00
Ensure 0 score from miss judgements, add test
This commit is contained in:
parent
da07354f05
commit
a4ad0bd174
41
osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs
Normal file
41
osu.Game.Tests/Gameplay/TestSceneScoreProcessor.cs
Normal file
@ -0,0 +1,41 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Gameplay
|
||||
{
|
||||
[HeadlessTest]
|
||||
public class TestSceneScoreProcessor : OsuTestScene
|
||||
{
|
||||
[Test]
|
||||
public void TestNoScoreIncreaseFromMiss()
|
||||
{
|
||||
var beatmap = new Beatmap<TestHitObject> { HitObjects = { new TestHitObject() } };
|
||||
|
||||
var scoreProcessor = new ScoreProcessor();
|
||||
scoreProcessor.ApplyBeatmap(beatmap);
|
||||
|
||||
// Apply a miss judgement
|
||||
scoreProcessor.ApplyResult(new JudgementResult(new TestHitObject(), new TestJudgement()) { Type = HitResult.Miss });
|
||||
|
||||
Assert.That(scoreProcessor.TotalScore.Value, Is.EqualTo(0.0));
|
||||
}
|
||||
|
||||
private class TestHitObject : HitObject
|
||||
{
|
||||
public override Judgement CreateJudgement() => new TestJudgement();
|
||||
}
|
||||
|
||||
private class TestJudgement : Judgement
|
||||
{
|
||||
protected override int NumericResultFor(HitResult result) => 100;
|
||||
}
|
||||
}
|
||||
}
|
@ -133,17 +133,19 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
}
|
||||
|
||||
double scoreIncrease = result.Type == HitResult.Miss ? 0 : result.Judgement.NumericResultFor(result);
|
||||
|
||||
if (result.Judgement.IsBonus)
|
||||
{
|
||||
if (result.IsHit)
|
||||
bonusScore += result.Judgement.NumericResultFor(result);
|
||||
bonusScore += scoreIncrease;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.HasResult)
|
||||
scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) + 1;
|
||||
|
||||
baseScore += result.Judgement.NumericResultFor(result);
|
||||
baseScore += scoreIncrease;
|
||||
rollingMaxBaseScore += result.Judgement.MaxNumericResult;
|
||||
}
|
||||
|
||||
@ -169,17 +171,19 @@ namespace osu.Game.Rulesets.Scoring
|
||||
if (result.FailedAtJudgement)
|
||||
return;
|
||||
|
||||
double scoreIncrease = result.Type == HitResult.Miss ? 0 : result.Judgement.NumericResultFor(result);
|
||||
|
||||
if (result.Judgement.IsBonus)
|
||||
{
|
||||
if (result.IsHit)
|
||||
bonusScore -= result.Judgement.NumericResultFor(result);
|
||||
bonusScore -= scoreIncrease;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (result.HasResult)
|
||||
scoreResultCounts[result.Type] = scoreResultCounts.GetOrDefault(result.Type) - 1;
|
||||
|
||||
baseScore -= result.Judgement.NumericResultFor(result);
|
||||
baseScore -= scoreIncrease;
|
||||
rollingMaxBaseScore -= result.Judgement.MaxNumericResult;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user