mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Add tests
This commit is contained in:
parent
d47a8c0826
commit
a9c4b5ac4e
60
osu.Game.Tests/Visual/Gameplay/TestSceneFailJudgement.cs
Normal file
60
osu.Game.Tests/Visual/Gameplay/TestSceneFailJudgement.cs
Normal file
@ -0,0 +1,60 @@
|
||||
// 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 System;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
public class TestSceneFailJudgement : AllPlayersTestScene
|
||||
{
|
||||
protected override Player CreatePlayer(Ruleset ruleset)
|
||||
{
|
||||
Mods.Value = Array.Empty<Mod>();
|
||||
|
||||
var beatmap = Beatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo, Array.Empty<Mod>());
|
||||
return new FailPlayer(ruleset.GetAutoplayMod().CreateReplayScore(beatmap));
|
||||
}
|
||||
|
||||
protected override void AddCheckSteps()
|
||||
{
|
||||
AddUntilStep("wait for fail", () => Player.HasFailed);
|
||||
AddUntilStep("wait for multiple judged objects", () => ((FailPlayer)Player).DrawableRuleset.Playfield.AllHitObjects.Count(h => h.AllJudged) > 1);
|
||||
AddAssert("total judgements == 1", () =>
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
foreach (var stat in (HitResult[])Enum.GetValues(typeof(HitResult)))
|
||||
count += ((FailPlayer)Player).ScoreProcessor.GetStatistic(stat);
|
||||
|
||||
return count == 1;
|
||||
});
|
||||
}
|
||||
|
||||
private class FailPlayer : ReplayPlayer
|
||||
{
|
||||
public new DrawableRuleset DrawableRuleset => base.DrawableRuleset;
|
||||
|
||||
public new ScoreProcessor ScoreProcessor => base.ScoreProcessor;
|
||||
|
||||
protected override bool PauseOnFocusLost => false;
|
||||
|
||||
public FailPlayer(Score score)
|
||||
: base(score, false, false)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
ScoreProcessor.FailConditions += (_, __) => true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -193,7 +193,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
score.Statistics[result] = GetStatistic(result);
|
||||
}
|
||||
|
||||
protected abstract int GetStatistic(HitResult result);
|
||||
public abstract int GetStatistic(HitResult result);
|
||||
|
||||
public abstract double GetStandardisedScore();
|
||||
}
|
||||
@ -421,7 +421,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
}
|
||||
|
||||
protected override int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
|
||||
public override int GetStatistic(HitResult result) => scoreResultCounts.GetOrDefault(result);
|
||||
|
||||
public override double GetStandardisedScore() => getScore(ScoringMode.Standardised);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user