1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 22:22:56 +08:00

Merge pull request #1538 from ppy/osu/sudden-death

Implement Sudden Death and Perfect mods
This commit is contained in:
Dean Herbert 2017-11-21 18:23:59 +09:00 committed by GitHub
commit 862529a452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 7 deletions

View File

@ -53,7 +53,7 @@ namespace osu.Game.Rulesets.Taiko.Scoring
/// <summary> /// <summary>
/// Taiko fails at the end of the map if the player has not half-filled their HP bar. /// Taiko fails at the end of the map if the player has not half-filled their HP bar.
/// </summary> /// </summary>
protected override bool FailCondition => Hits == MaxHits && Health.Value <= 0.5; protected override bool DefaultFailCondition => Hits == MaxHits && Health.Value <= 0.5;
private double hpIncreaseTick; private double hpIncreaseTick;
private double hpIncreaseGreat; private double hpIncreaseGreat;

View File

@ -0,0 +1,15 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mods
{
/// <summary>
/// An interface for mods that make general adjustments to score processor.
/// </summary>
public interface IApplicableToScoreProcessor
{
void ApplyToScoreProcessor(ScoreProcessor scoreProcessor);
}
}

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
public abstract class ModPerfect : ModSuddenDeath public abstract class ModPerfect : ModSuddenDeath
@ -8,5 +10,7 @@ namespace osu.Game.Rulesets.Mods
public override string Name => "Perfect"; public override string Name => "Perfect";
public override string ShortenedName => "PF"; public override string ShortenedName => "PF";
public override string Description => "SS or quit."; public override string Description => "SS or quit.";
protected override bool FailCondition(ScoreProcessor scoreProcessor) => scoreProcessor.Accuracy.Value != 1;
} }
} }

View File

@ -3,10 +3,11 @@
using System; using System;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
public abstract class ModSuddenDeath : Mod public abstract class ModSuddenDeath : Mod, IApplicableToScoreProcessor
{ {
public override string Name => "Sudden Death"; public override string Name => "Sudden Death";
public override string ShortenedName => "SD"; public override string ShortenedName => "SD";
@ -16,5 +17,12 @@ namespace osu.Game.Rulesets.Mods
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;
public override bool Ranked => true; public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) }; public override Type[] IncompatibleMods => new[] { typeof(ModNoFail), typeof(ModRelax), typeof(ModAutoplay) };
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
scoreProcessor.FailConditions += FailCondition;
}
protected virtual bool FailCondition(ScoreProcessor scoreProcessor) => scoreProcessor.Combo.Value == 0;
} }
} }

View File

@ -31,6 +31,11 @@ namespace osu.Game.Rulesets.Scoring
/// </summary> /// </summary>
public event Action<Judgement> NewJudgement; public event Action<Judgement> NewJudgement;
/// <summary>
/// Additional conditions on top of <see cref="DefaultFailCondition"/> that cause a failing state.
/// </summary>
public event Func<ScoreProcessor, bool> FailConditions;
/// <summary> /// <summary>
/// The current total score. /// The current total score.
/// </summary> /// </summary>
@ -72,9 +77,9 @@ namespace osu.Game.Rulesets.Scoring
public virtual bool HasFailed { get; private set; } public virtual bool HasFailed { get; private set; }
/// <summary> /// <summary>
/// The conditions for failing. /// The default conditions for failing.
/// </summary> /// </summary>
protected virtual bool FailCondition => Health.Value == Health.MinValue; protected virtual bool DefaultFailCondition => Health.Value == Health.MinValue;
protected ScoreProcessor() protected ScoreProcessor()
{ {
@ -121,7 +126,10 @@ namespace osu.Game.Rulesets.Scoring
/// </summary> /// </summary>
protected void UpdateFailed() protected void UpdateFailed()
{ {
if (HasFailed || !FailCondition) if (HasFailed)
return;
if (!DefaultFailCondition && FailConditions?.Invoke(this) != true)
return; return;
if (Failed?.Invoke() != false) if (Failed?.Invoke() != false)

View File

@ -227,6 +227,9 @@ namespace osu.Game.Screens.Play
// Bind ScoreProcessor to ourselves // Bind ScoreProcessor to ourselves
scoreProcessor.AllJudged += onCompletion; scoreProcessor.AllJudged += onCompletion;
scoreProcessor.Failed += onFail; scoreProcessor.Failed += onFail;
foreach (var mod in Beatmap.Value.Mods.Value.OfType<IApplicableToScoreProcessor>())
mod.ApplyToScoreProcessor(scoreProcessor);
} }
private void applyRateFromMods() private void applyRateFromMods()

View File

@ -298,6 +298,7 @@
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableTotalScore.cs" /> <Compile Include="Overlays\Profile\Sections\Ranks\DrawableTotalScore.cs" />
<Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" /> <Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" />
<Compile Include="Overlays\Settings\SettingsButton.cs" /> <Compile Include="Overlays\Settings\SettingsButton.cs" />
<Compile Include="Rulesets\Mods\IApplicableToScoreProcessor.cs" />
<Compile Include="Screens\Edit\Screens\Compose\Timeline\BeatmapWaveformGraph.cs" /> <Compile Include="Screens\Edit\Screens\Compose\Timeline\BeatmapWaveformGraph.cs" />
<Compile Include="Beatmaps\Drawables\DifficultyColouredContainer.cs" /> <Compile Include="Beatmaps\Drawables\DifficultyColouredContainer.cs" />
<Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" /> <Compile Include="Beatmaps\Drawables\DifficultyIcon.cs" />