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
|
|
|
|
{
|
2020-03-05 23:36:05 +08:00
|
|
|
public abstract 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
|
|
|
|
2020-04-17 15:56:01 +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
|
|
|
|
{
|
2020-06-04 05:40:24 +08:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2020-03-08 21:18:45 +08:00
|
|
|
protected override TestPlayer CreateModPlayer(Ruleset ruleset) => new PerfectModTestPlayer();
|
2020-03-02 11:42:48 +08:00
|
|
|
|
|
|
|
private class PerfectModTestPlayer : TestPlayer
|
|
|
|
{
|
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)
|
2020-04-19 10:36:04 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|