2020-03-02 03:42:48 +00: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
|
|
|
|
{
|
2020-03-05 15:36:05 +00:00
|
|
|
public abstract class ModPerfectTestScene : ModTestScene
|
2020-03-02 03:42:48 +00:00
|
|
|
{
|
2020-03-02 04:24:02 +00:00
|
|
|
private readonly Ruleset ruleset;
|
2020-03-05 15:36:05 +00:00
|
|
|
private readonly ModPerfect mod;
|
2020-03-02 03:42:48 +00:00
|
|
|
|
2020-03-05 15:36:05 +00:00
|
|
|
protected ModPerfectTestScene(Ruleset ruleset, ModPerfect mod)
|
2020-03-02 03:42:48 +00:00
|
|
|
: base(ruleset)
|
|
|
|
{
|
2020-03-02 04:24:02 +00:00
|
|
|
this.ruleset = ruleset;
|
2020-03-05 15:36:05 +00:00
|
|
|
this.mod = mod;
|
2020-03-02 03:42:48 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 15:36:05 +00:00
|
|
|
protected void CreateHitObjectTest(HitObjectTestCase testCaseData, bool shouldMiss) => CreateModTest(new ModTestData
|
2020-03-02 03:42:48 +00:00
|
|
|
{
|
2020-03-05 15:36:05 +00:00
|
|
|
Mod = mod,
|
2020-03-02 03:42:48 +00:00
|
|
|
Beatmap = new Beatmap
|
|
|
|
{
|
2020-03-02 04:24:02 +00:00
|
|
|
BeatmapInfo = { Ruleset = ruleset.RulesetInfo },
|
2020-03-02 03:42:48 +00:00
|
|
|
HitObjects = { testCaseData.HitObject }
|
|
|
|
},
|
|
|
|
Autoplay = !shouldMiss,
|
|
|
|
PassCondition = () => ((PerfectModTestPlayer)Player).CheckFailed(shouldMiss && testCaseData.FailOnMiss)
|
|
|
|
});
|
|
|
|
|
2020-03-05 15:36:05 +00:00
|
|
|
protected override TestPlayer CreatePlayer(Ruleset ruleset) => new PerfectModTestPlayer();
|
2020-03-02 03:42:48 +00:00
|
|
|
|
|
|
|
private class PerfectModTestPlayer : TestPlayer
|
|
|
|
{
|
|
|
|
protected override bool AllowFail => true;
|
|
|
|
|
|
|
|
public bool CheckFailed(bool failed)
|
|
|
|
{
|
|
|
|
if (!failed)
|
|
|
|
return ScoreProcessor.HasCompleted && !HealthProcessor.HasFailed;
|
|
|
|
|
2020-03-02 04:24:07 +00:00
|
|
|
return HealthProcessor.HasFailed;
|
2020-03-02 03:42:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected class HitObjectTestCase
|
|
|
|
{
|
|
|
|
public readonly HitObject HitObject;
|
|
|
|
public readonly bool FailOnMiss;
|
|
|
|
|
|
|
|
public HitObjectTestCase(HitObject hitObject, bool failOnMiss = true)
|
|
|
|
{
|
|
|
|
HitObject = hitObject;
|
|
|
|
FailOnMiss = failOnMiss;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|