From de4d8eb1965a82d5d59c8bc0d87476cdec03d539 Mon Sep 17 00:00:00 2001 From: Brayzure Date: Sat, 18 Nov 2017 01:28:09 -0500 Subject: [PATCH] Implement Sudden Death and Perfect - Two additional fail conditions --- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 23 ++++++++++++++++++--- osu.Game/Screens/Play/Player.cs | 6 ++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 4dd88600b2..f579b94c69 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -66,6 +66,8 @@ namespace osu.Game.Rulesets.Scoring /// protected virtual bool HasCompleted => false; + public int strictFail = 0; + /// /// Whether this ScoreProcessor has already triggered the failed state. /// @@ -76,6 +78,16 @@ namespace osu.Game.Rulesets.Scoring /// protected virtual bool FailCondition => Health.Value == Health.MinValue; + /// + /// The conditions for failing if the Sudden Death mod is enabled. + /// + protected virtual bool SuddenDeathFailCondition => Combo.Value != HighestCombo.Value; + + /// + /// The conditions for failing if the Perfect mod is enabled. + /// + protected virtual bool PerfectFailCondition => Accuracy.Value != 1; + protected ScoreProcessor() { Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); }; @@ -121,11 +133,16 @@ namespace osu.Game.Rulesets.Scoring /// protected void UpdateFailed() { - if (HasFailed || !FailCondition) + if (HasFailed) return; - if (Failed?.Invoke() != false) - HasFailed = true; + if(FailCondition || + (strictFail==1 && SuddenDeathFailCondition) || + (strictFail==2 && PerfectFailCondition)) + { + if (Failed?.Invoke() != false) + HasFailed = true; + } } /// diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 3e57e18963..2603fee769 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -227,6 +227,12 @@ namespace osu.Game.Screens.Play // Bind ScoreProcessor to ourselves scoreProcessor.AllJudged += onCompletion; scoreProcessor.Failed += onFail; + + if (Beatmap.Value.Mods.Value.Any(m => m.Name == "Sudden Death")) + scoreProcessor.strictFail = 1; + + if (Beatmap.Value.Mods.Value.Any(m => m.Name == "Perfect")) + scoreProcessor.strictFail = 2; } private void applyRateFromMods()