mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:03:13 +08:00
Add AdjustRank and use it in Hidden Mod
This commit is contained in:
parent
cfb3c38c3a
commit
c6b3197dd0
@ -12,6 +12,7 @@ using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -41,6 +42,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
scoreProcessor.Health.ValueChanged += health => { blinds.AnimateClosedness((float)health.NewValue); };
|
||||
}
|
||||
|
||||
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
||||
|
||||
/// <summary>
|
||||
/// Element for the Blinds mod drawing 2 black boxes covering the whole screen which resize inside a restricted area with some leniency.
|
||||
/// </summary>
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Screens.Play;
|
||||
|
||||
@ -110,6 +111,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
Applied = true;
|
||||
}
|
||||
|
||||
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
||||
}
|
||||
|
||||
private class TestPlayer : Player
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
@ -11,5 +12,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public interface IApplicableToScoreProcessor : IApplicableMod
|
||||
{
|
||||
void ApplyToScoreProcessor(ScoreProcessor scoreProcessor);
|
||||
|
||||
ScoreRank AdjustRank(ScoreRank rank, double accuracy);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -46,6 +47,8 @@ namespace osu.Game.Rulesets.Mods
|
||||
Combo.BindTo(scoreProcessor.Combo);
|
||||
}
|
||||
|
||||
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
||||
|
||||
public virtual void ApplyToDrawableRuleset(DrawableRuleset<T> drawableRuleset)
|
||||
{
|
||||
var flashlight = CreateFlashlight();
|
||||
|
@ -9,6 +9,7 @@ using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
@ -35,7 +36,22 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
||||
{
|
||||
scoreProcessor.AdjustRank = true;
|
||||
// Default value of ScoreProcessor's Rank in Hidden Mod should bes SS+
|
||||
scoreProcessor.Rank.Value = ScoreRank.XH;
|
||||
}
|
||||
|
||||
// TODO: Other mods that uses AdjustRank might have some issues due to rank changes
|
||||
public ScoreRank AdjustRank(ScoreRank rank, double accuracy)
|
||||
{
|
||||
switch (rank)
|
||||
{
|
||||
case ScoreRank.X:
|
||||
return ScoreRank.XH;
|
||||
case ScoreRank.S:
|
||||
return ScoreRank.SH;
|
||||
default:
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ApplyHiddenState(DrawableHitObject hitObject, ArmedState state)
|
||||
|
@ -5,6 +5,7 @@ using System;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
@ -24,6 +25,8 @@ namespace osu.Game.Rulesets.Mods
|
||||
scoreProcessor.FailConditions += FailCondition;
|
||||
}
|
||||
|
||||
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
||||
|
||||
protected virtual bool FailCondition(ScoreProcessor scoreProcessor) => scoreProcessor.Combo.Value == 0;
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,11 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
@ -60,6 +62,11 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// </summary>
|
||||
public readonly BindableInt Combo = new BindableInt();
|
||||
|
||||
/// <summary>
|
||||
/// The current selected mods
|
||||
/// </summary>
|
||||
public readonly Bindable<IReadOnlyList<Mod>> Mods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
|
||||
/// <summary>
|
||||
/// Create a <see cref="HitWindows"/> for this processor.
|
||||
/// </summary>
|
||||
@ -95,34 +102,22 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// </summary>
|
||||
protected virtual bool DefaultFailCondition => Health.Value == Health.MinValue;
|
||||
|
||||
private bool adjustRank;
|
||||
|
||||
/// <summary>
|
||||
/// Used by specific mods to adjust <see cref="Rank"/>.
|
||||
/// </summary>
|
||||
public bool AdjustRank
|
||||
{
|
||||
get => adjustRank;
|
||||
|
||||
set
|
||||
{
|
||||
adjustRank = value;
|
||||
Rank.Value = rankFrom(Accuracy.Value); // Update rank immediately if AdjustRank was changed
|
||||
}
|
||||
}
|
||||
|
||||
protected ScoreProcessor()
|
||||
{
|
||||
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
|
||||
Accuracy.ValueChanged += delegate { Rank.Value = rankFrom(Accuracy.Value); };
|
||||
Accuracy.ValueChanged += delegate
|
||||
{
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
Rank.Value = mod.AdjustRank(rankFrom(Accuracy.Value), Accuracy.Value);
|
||||
};
|
||||
}
|
||||
|
||||
private ScoreRank rankFrom(double acc)
|
||||
{
|
||||
if (acc == 1)
|
||||
return (adjustRank ? ScoreRank.XH : ScoreRank.X);
|
||||
return ScoreRank.X;
|
||||
if (acc > 0.95)
|
||||
return (adjustRank ? ScoreRank.SH : ScoreRank.S);
|
||||
return ScoreRank.S;
|
||||
if (acc > 0.9)
|
||||
return ScoreRank.A;
|
||||
if (acc > 0.8)
|
||||
@ -146,7 +141,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
Rank.Value = ScoreRank.X;
|
||||
HighestCombo.Value = 0;
|
||||
|
||||
AdjustRank = false;
|
||||
HasFailed = false;
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,8 @@ namespace osu.Game.Screens.Play
|
||||
showStoryboard = config.GetBindable<bool>(OsuSetting.ShowStoryboard);
|
||||
|
||||
ScoreProcessor = DrawableRuleset.CreateScoreProcessor();
|
||||
ScoreProcessor.Mods.BindTo(Mods);
|
||||
|
||||
if (!ScoreProcessor.Mode.Disabled)
|
||||
config.BindWith(OsuSetting.ScoreDisplayMode, ScoreProcessor.Mode);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user