Combine RestartOnFail into FailOverride

This commit is contained in:
Paul Teng 2018-10-30 07:12:06 -04:00
parent 52b9a3f5e9
commit 007dfedbb7
7 changed files with 12 additions and 19 deletions

View File

@ -19,6 +19,7 @@ namespace osu.Game.Rulesets.Osu.Mods
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(OsuModAutopilot)).ToArray();
public bool AllowFail => false;
public bool RestartOnFail => false;
public void Update(Playfield playfield)
{

View File

@ -12,5 +12,10 @@ namespace osu.Game.Rulesets.Mods
/// Whether we should allow failing at the current point in time.
/// </summary>
bool AllowFail { get; }
/// <summary>
/// Whether we want to restart on fail. Only used if AllowFail is true.
/// </summary>
bool RestartOnFail { get; }
}
}

View File

@ -1,16 +0,0 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
namespace osu.Game.Rulesets.Mods
{
/// <summary>
/// Represents a mod which can request to restart on fail.
/// </summary>
public interface IApplicableRestartOnFail : IApplicableMod
{
/// <summary>
/// Whether we allow restarting
/// </summary>
bool AllowRestart { get; }
}
}

View File

@ -30,6 +30,7 @@ namespace osu.Game.Rulesets.Mods
public override string Description => "Watch a perfect automated play through the song.";
public override double ScoreMultiplier => 1;
public bool AllowFail => false;
public bool RestartOnFail => false;
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail) };
}
}

View File

@ -21,5 +21,6 @@ namespace osu.Game.Rulesets.Mods
/// We never fail, 'yo.
/// </summary>
public bool AllowFail => false;
public bool RestartOnFail => false;
}
}

View File

@ -7,7 +7,7 @@ using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModSuddenDeath : Mod, IApplicableToScoreProcessor, IApplicableRestartOnFail
public abstract class ModSuddenDeath : Mod, IApplicableToScoreProcessor, IApplicableFailOverride
{
public override string Name => "Sudden Death";
public override string ShortenedName => "SD";
@ -18,7 +18,8 @@ namespace osu.Game.Rulesets.Mods
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
public bool AllowRestart => true;
public bool AllowFail => true;
public bool RestartOnFail => true;
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{

View File

@ -289,7 +289,7 @@ namespace osu.Game.Screens.Play
if (Beatmap.Value.Mods.Value.OfType<IApplicableFailOverride>().Any(m => !m.AllowFail))
return false;
if (Beatmap.Value.Mods.Value.OfType<IApplicableRestartOnFail>().Any(m => m.AllowRestart))
if (Beatmap.Value.Mods.Value.OfType<IApplicableFailOverride>().Any(m => m.RestartOnFail))
{
Restart();
return false;