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-05 15:36:05 +00:00
|
|
|
private readonly ModPerfect mod;
|
2020-03-02 03:42:48 +00:00
|
|
|
|
2020-04-17 07:56:01 +00:00
|
|
|
protected ModPerfectTestScene(ModPerfect mod)
|
2020-03-02 03:42:48 +00:00
|
|
|
{
|
2020-03-05 15:36:05 +00:00
|
|
|
this.mod = mod;
|
2020-03-02 03:42:48 +00:00
|
|
|
}
|
|
|
|
|
2020-03-10 15:36:56 +00:00
|
|
|
protected void CreateHitObjectTest(HitObjectTestData testData, 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-06-03 21:40:24 +00:00
|
|
|
BeatmapInfo = { Ruleset = CreatePlayerRuleset().RulesetInfo },
|
2020-03-10 15:36:56 +00:00
|
|
|
HitObjects = { testData.HitObject }
|
2020-03-02 03:42:48 +00:00
|
|
|
},
|
|
|
|
Autoplay = !shouldMiss,
|
2020-03-10 15:36:56 +00:00
|
|
|
PassCondition = () => ((PerfectModTestPlayer)Player).CheckFailed(shouldMiss && testData.FailOnMiss)
|
2020-03-02 03:42:48 +00:00
|
|
|
});
|
|
|
|
|
2020-03-08 13:18:45 +00:00
|
|
|
protected override TestPlayer CreateModPlayer(Ruleset ruleset) => new PerfectModTestPlayer();
|
2020-03-02 03:42:48 +00:00
|
|
|
|
|
|
|
private class PerfectModTestPlayer : TestPlayer
|
|
|
|
{
|
2020-03-08 13:08:49 +00:00
|
|
|
public PerfectModTestPlayer()
|
|
|
|
: base(showResults: false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-05-12 11:26:34 +00:00
|
|
|
protected override bool CheckModsAllowFailure() => true;
|
2020-03-02 03:42:48 +00:00
|
|
|
|
|
|
|
public bool CheckFailed(bool failed)
|
|
|
|
{
|
|
|
|
if (!failed)
|
2020-04-19 02:36:04 +00:00
|
|
|
return ScoreProcessor.HasCompleted.Value && !HealthProcessor.HasFailed;
|
2020-03-02 03:42:48 +00:00
|
|
|
|
2020-03-02 04:24:07 +00:00
|
|
|
return HealthProcessor.HasFailed;
|
2020-03-02 03:42:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-10 15:36:56 +00:00
|
|
|
protected class HitObjectTestData
|
2020-03-02 03:42:48 +00:00
|
|
|
{
|
|
|
|
public readonly HitObject HitObject;
|
|
|
|
public readonly bool FailOnMiss;
|
|
|
|
|
2020-03-10 15:36:56 +00:00
|
|
|
public HitObjectTestData(HitObject hitObject, bool failOnMiss = true)
|
2020-03-02 03:42:48 +00:00
|
|
|
{
|
|
|
|
HitObject = hitObject;
|
|
|
|
FailOnMiss = failOnMiss;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|