1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-17 12:22:55 +08:00
osu-lazer/osu.Game/Tests/Visual/ModFailConditionTestScene.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
2.1 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.
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Tests.Visual
{
2023-12-22 15:43:09 +08:00
public abstract partial class ModFailConditionTestScene : ModTestScene
2020-03-02 11:42:48 +08:00
{
2023-12-22 15:43:09 +08:00
private readonly ModFailCondition mod;
2020-03-02 11:42:48 +08:00
2023-12-22 15:43:09 +08:00
protected ModFailConditionTestScene(ModFailCondition 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,
2023-12-22 15:43:09 +08:00
PassCondition = () => ((ModFailConditionTestPlayer)Player).CheckFailed(shouldMiss && testData.FailOnMiss)
2020-03-02 11:42:48 +08:00
});
2023-12-22 15:43:09 +08:00
protected override TestPlayer CreateModPlayer(Ruleset ruleset) => new ModFailConditionTestPlayer(CurrentTestData, AllowFail);
2020-03-02 11:42:48 +08:00
2023-12-22 15:43:09 +08:00
protected partial class ModFailConditionTestPlayer : ModTestPlayer
2020-03-02 11:42:48 +08:00
{
2023-12-22 15:43:09 +08:00
public ModFailConditionTestPlayer(ModTestData data, bool allowFail)
2023-12-22 12:38:52 +08:00
: base(data, allowFail)
2020-03-08 21:08:49 +08:00
{
}
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;
}
}
}
}