1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 05:17:29 +08:00
osu-lazer/osu.Game/Tests/Visual/ModPerfectTestScene.cs

67 lines
2.0 KiB
C#
Raw Normal View History

2020-03-02 11:42:48 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
2020-03-02 11:42:48 +08:00
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Tests.Visual
{
2022-11-24 13:32:20 +08:00
public abstract partial class ModPerfectTestScene : ModTestScene
2020-03-02 11:42:48 +08:00
{
2020-03-05 23:36:05 +08:00
private readonly ModPerfect mod;
2020-03-02 11:42:48 +08:00
protected ModPerfectTestScene(ModPerfect mod)
2020-03-02 11:42:48 +08:00
{
2020-03-05 23:36:05 +08:00
this.mod = mod;
2020-03-02 11:42:48 +08:00
}
2020-03-10 23:36:56 +08:00
protected void CreateHitObjectTest(HitObjectTestData testData, bool shouldMiss) => CreateModTest(new ModTestData
2020-03-02 11:42:48 +08:00
{
2020-03-05 23:36:05 +08:00
Mod = mod,
2020-03-02 11:42:48 +08:00
Beatmap = new Beatmap
{
BeatmapInfo = { Ruleset = CreatePlayerRuleset().RulesetInfo },
2020-03-10 23:36:56 +08:00
HitObjects = { testData.HitObject }
2020-03-02 11:42:48 +08:00
},
Autoplay = !shouldMiss,
2020-03-10 23:36:56 +08:00
PassCondition = () => ((PerfectModTestPlayer)Player).CheckFailed(shouldMiss && testData.FailOnMiss)
2020-03-02 11:42:48 +08:00
});
protected override TestPlayer CreateModPlayer(Ruleset ruleset) => new PerfectModTestPlayer();
2020-03-02 11:42:48 +08:00
2022-11-24 13:32:20 +08:00
private partial class PerfectModTestPlayer : TestPlayer
2020-03-02 11:42:48 +08:00
{
2020-03-08 21:08:49 +08:00
public PerfectModTestPlayer()
: base(showResults: false)
{
}
2020-05-12 19:26:34 +08:00
protected override bool CheckModsAllowFailure() => true;
2020-03-02 11:42:48 +08:00
public bool CheckFailed(bool failed)
{
if (!failed)
return ScoreProcessor.HasCompleted.Value && !HealthProcessor.HasFailed;
2020-03-02 11:42:48 +08:00
2020-03-02 12:24:07 +08:00
return HealthProcessor.HasFailed;
2020-03-02 11:42:48 +08:00
}
}
2020-03-10 23:36:56 +08:00
protected class HitObjectTestData
2020-03-02 11:42:48 +08:00
{
public readonly HitObject HitObject;
public readonly bool FailOnMiss;
2020-03-10 23:36:56 +08:00
public HitObjectTestData(HitObject hitObject, bool failOnMiss = true)
2020-03-02 11:42:48 +08:00
{
HitObject = hitObject;
FailOnMiss = failOnMiss;
}
}
}
}