mirror of
https://github.com/osukey/osukey.git
synced 2025-05-30 01:47:30 +09:00
Merge pull request #11200 from PercyDan54/auto-restart
Make Sudden Death&Perfect auto restart toggleable
This commit is contained in:
commit
f8b32b6e10
55
osu.Game.Tests/Visual/Mods/TestSceneModFailCondition.cs
Normal file
55
osu.Game.Tests/Visual/Mods/TestSceneModFailCondition.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
// 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 System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
|
using osu.Game.Screens.Play;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Mods
|
||||||
|
{
|
||||||
|
public class TestSceneModFailCondition : ModTestScene
|
||||||
|
{
|
||||||
|
private bool restartRequested;
|
||||||
|
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
|
protected override TestPlayer CreateModPlayer(Ruleset ruleset)
|
||||||
|
{
|
||||||
|
var player = base.CreateModPlayer(ruleset);
|
||||||
|
player.RestartRequested = () => restartRequested = true;
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool AllowFail => true;
|
||||||
|
|
||||||
|
[SetUpSteps]
|
||||||
|
public void SetUp()
|
||||||
|
{
|
||||||
|
AddStep("reset flag", () => restartRequested = false);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRestartOnFailDisabled() => CreateModTest(new ModTestData
|
||||||
|
{
|
||||||
|
Autoplay = false,
|
||||||
|
Mod = new OsuModSuddenDeath(),
|
||||||
|
PassCondition = () => !restartRequested && Player.ChildrenOfType<FailOverlay>().Single().State.Value == Visibility.Visible
|
||||||
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestRestartOnFailEnabled() => CreateModTest(new ModTestData
|
||||||
|
{
|
||||||
|
Autoplay = false,
|
||||||
|
Mod = new OsuModSuddenDeath
|
||||||
|
{
|
||||||
|
Restart = { Value = true }
|
||||||
|
},
|
||||||
|
PassCondition = () => restartRequested && Player.ChildrenOfType<FailOverlay>().Single().State.Value == Visibility.Hidden
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,8 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
|
|
||||||
@ -11,9 +13,12 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
{
|
{
|
||||||
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
|
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
|
||||||
|
|
||||||
|
[SettingSource("Restart on fail", "Automatically restarts when failed.")]
|
||||||
|
public BindableBool Restart { get; } = new BindableBool();
|
||||||
|
|
||||||
public virtual bool PerformFail() => true;
|
public virtual bool PerformFail() => true;
|
||||||
|
|
||||||
public virtual bool RestartOnFail => true;
|
public virtual bool RestartOnFail => Restart.Value;
|
||||||
|
|
||||||
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,11 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModSuddenDeath)).ToArray();
|
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModSuddenDeath)).ToArray();
|
||||||
|
|
||||||
|
protected ModPerfect()
|
||||||
|
{
|
||||||
|
Restart.Value = Restart.Default = true;
|
||||||
|
}
|
||||||
|
|
||||||
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result)
|
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result)
|
||||||
=> result.Type.AffectsAccuracy()
|
=> result.Type.AffectsAccuracy()
|
||||||
&& result.Type != result.Judgement.MaxResult;
|
&& result.Type != result.Judgement.MaxResult;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user