Make SD and PF incompatible with each other

This commit is contained in:
smoogipoo 2021-02-24 14:32:50 +09:00
parent dd702ccfd2
commit 30a58691f0
3 changed files with 37 additions and 12 deletions

View File

@ -0,0 +1,25 @@
// 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;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModFailCondition : Mod, IApplicableToHealthProcessor, IApplicableFailOverride
{
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
public bool PerformFail() => true;
public bool RestartOnFail => true;
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{
healthProcessor.FailConditions += FailCondition;
}
protected abstract bool FailCondition(HealthProcessor healthProcessor, JudgementResult result);
}
}

View File

@ -1,6 +1,8 @@
// 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;
using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Judgements;
@ -8,13 +10,18 @@
namespace osu.Game.Rulesets.Mods
{
public abstract class ModPerfect : ModSuddenDeath
public abstract class ModPerfect : ModFailCondition
{
public override string Name => "Perfect";
public override string Acronym => "PF";
public override IconUsage? Icon => OsuIcon.ModPerfect;
public override ModType Type => ModType.DifficultyIncrease;
public override bool Ranked => true;
public override double ScoreMultiplier => 1;
public override string Description => "SS or quit.";
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModSuddenDeath)).ToArray();
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result)
=> result.Type.AffectsAccuracy()
&& result.Type != result.Judgement.MaxResult;

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Rulesets.Judgements;
@ -9,7 +10,7 @@
namespace osu.Game.Rulesets.Mods
{
public abstract class ModSuddenDeath : Mod, IApplicableToHealthProcessor, IApplicableFailOverride
public abstract class ModSuddenDeath : ModFailCondition
{
public override string Name => "Sudden Death";
public override string Acronym => "SD";
@ -18,18 +19,10 @@ public abstract class ModSuddenDeath : Mod, IApplicableToHealthProcessor, IAppli
public override string Description => "Miss and fail.";
public override double ScoreMultiplier => 1;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
public bool PerformFail() => true;
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModPerfect)).ToArray();
public bool RestartOnFail => true;
public void ApplyToHealthProcessor(HealthProcessor healthProcessor)
{
healthProcessor.FailConditions += FailCondition;
}
protected virtual bool FailCondition(HealthProcessor healthProcessor, JudgementResult result)
protected override bool FailCondition(HealthProcessor healthProcessor, JudgementResult result)
=> result.Type.AffectsCombo()
&& !result.IsHit;
}