mirror of
https://github.com/ppy/osu
synced 2024-12-28 09:52:56 +00:00
bbad70c3f0
Just a workaround for now, a better fix may be to put the test data creation in an action that is guaranteed to be invoked after the test scene has fully loaded (all dependencies would've been resolved by then).
65 lines
1.9 KiB
C#
65 lines
1.9 KiB
C#
// 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 osu.Game.Beatmaps;
|
|
using osu.Game.Rulesets;
|
|
using osu.Game.Rulesets.Mods;
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
namespace osu.Game.Tests.Visual
|
|
{
|
|
public abstract class ModPerfectTestScene : ModTestScene
|
|
{
|
|
private readonly ModPerfect mod;
|
|
|
|
protected ModPerfectTestScene(ModPerfect mod)
|
|
{
|
|
this.mod = mod;
|
|
}
|
|
|
|
protected void CreateHitObjectTest(HitObjectTestData testData, bool shouldMiss) => CreateModTest(new ModTestData
|
|
{
|
|
Mod = mod,
|
|
Beatmap = new Beatmap
|
|
{
|
|
BeatmapInfo = { Ruleset = CreatePlayerRuleset().RulesetInfo },
|
|
HitObjects = { testData.HitObject }
|
|
},
|
|
Autoplay = !shouldMiss,
|
|
PassCondition = () => ((PerfectModTestPlayer)Player).CheckFailed(shouldMiss && testData.FailOnMiss)
|
|
});
|
|
|
|
protected override TestPlayer CreateModPlayer(Ruleset ruleset) => new PerfectModTestPlayer();
|
|
|
|
private class PerfectModTestPlayer : TestPlayer
|
|
{
|
|
public PerfectModTestPlayer()
|
|
: base(showResults: false)
|
|
{
|
|
}
|
|
|
|
protected override bool CheckModsAllowFailure() => true;
|
|
|
|
public bool CheckFailed(bool failed)
|
|
{
|
|
if (!failed)
|
|
return ScoreProcessor.HasCompleted.Value && !HealthProcessor.HasFailed;
|
|
|
|
return HealthProcessor.HasFailed;
|
|
}
|
|
}
|
|
|
|
protected class HitObjectTestData
|
|
{
|
|
public readonly HitObject HitObject;
|
|
public readonly bool FailOnMiss;
|
|
|
|
public HitObjectTestData(HitObject hitObject, bool failOnMiss = true)
|
|
{
|
|
HitObject = hitObject;
|
|
FailOnMiss = failOnMiss;
|
|
}
|
|
}
|
|
}
|
|
}
|