mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Centralise accuracy cutoff constants and add lookup helper methods
This commit is contained in:
parent
57312279f0
commit
cf009432cc
@ -7,21 +7,28 @@ using System.Diagnostics;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Replays;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
public partial class ScoreProcessor : JudgementProcessor
|
||||
{
|
||||
private const double accuracy_cutoff_x = 1;
|
||||
private const double accuracy_cutoff_s = 0.95;
|
||||
private const double accuracy_cutoff_a = 0.9;
|
||||
private const double accuracy_cutoff_b = 0.8;
|
||||
private const double accuracy_cutoff_c = 0.7;
|
||||
private const double accuracy_cutoff_d = 0;
|
||||
|
||||
private const double max_score = 1000000;
|
||||
|
||||
/// <summary>
|
||||
@ -160,7 +167,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
Combo.ValueChanged += combo => HighestCombo.Value = Math.Max(HighestCombo.Value, combo.NewValue);
|
||||
Accuracy.ValueChanged += accuracy =>
|
||||
{
|
||||
Rank.Value = rankFrom(accuracy.NewValue);
|
||||
Rank.Value = RankFromAccuracy(accuracy.NewValue);
|
||||
foreach (var mod in Mods.Value.OfType<IApplicableToScoreProcessor>())
|
||||
Rank.Value = mod.AdjustRank(Rank.Value, accuracy.NewValue);
|
||||
};
|
||||
@ -369,22 +376,6 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
}
|
||||
|
||||
private ScoreRank rankFrom(double acc)
|
||||
{
|
||||
if (acc == 1)
|
||||
return ScoreRank.X;
|
||||
if (acc >= 0.95)
|
||||
return ScoreRank.S;
|
||||
if (acc >= 0.9)
|
||||
return ScoreRank.A;
|
||||
if (acc >= 0.8)
|
||||
return ScoreRank.B;
|
||||
if (acc >= 0.7)
|
||||
return ScoreRank.C;
|
||||
|
||||
return ScoreRank.D;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets this ScoreProcessor to a default state.
|
||||
/// </summary>
|
||||
@ -583,6 +574,70 @@ namespace osu.Game.Rulesets.Scoring
|
||||
hitEvents.Clear();
|
||||
}
|
||||
|
||||
#region Static helper methods
|
||||
|
||||
/// <summary>
|
||||
/// Given an accuracy (0..1), return the correct <see cref="ScoreRank"/>.
|
||||
/// </summary>
|
||||
public static ScoreRank RankFromAccuracy(double accuracy)
|
||||
{
|
||||
switch (accuracy)
|
||||
{
|
||||
case accuracy_cutoff_x:
|
||||
return ScoreRank.X;
|
||||
|
||||
case >= accuracy_cutoff_s:
|
||||
return ScoreRank.S;
|
||||
|
||||
case >= accuracy_cutoff_a:
|
||||
return ScoreRank.A;
|
||||
|
||||
case >= accuracy_cutoff_b:
|
||||
return ScoreRank.B;
|
||||
|
||||
case >= accuracy_cutoff_c:
|
||||
return ScoreRank.C;
|
||||
|
||||
default:
|
||||
return ScoreRank.D;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Given a <see cref="ScoreRank"/>, return the cutoff accuracy (0..1).
|
||||
/// Accuracy must be great or equal to the cutoff to qualify for the provided rank.
|
||||
/// </summary>
|
||||
public static double AccuracyCutoffFromRank(ScoreRank rank)
|
||||
{
|
||||
switch (rank)
|
||||
{
|
||||
case ScoreRank.X:
|
||||
case ScoreRank.XH:
|
||||
return accuracy_cutoff_x;
|
||||
|
||||
case ScoreRank.S:
|
||||
case ScoreRank.SH:
|
||||
return accuracy_cutoff_s;
|
||||
|
||||
case ScoreRank.A:
|
||||
return accuracy_cutoff_a;
|
||||
|
||||
case ScoreRank.B:
|
||||
return accuracy_cutoff_b;
|
||||
|
||||
case ScoreRank.C:
|
||||
return accuracy_cutoff_c;
|
||||
|
||||
case ScoreRank.D:
|
||||
return accuracy_cutoff_d;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(rank), rank, null);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Stores the required scoring data that fulfils the minimum requirements for a <see cref="ScoreProcessor"/> to calculate score.
|
||||
/// </summary>
|
||||
|
@ -17,6 +17,7 @@ using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
@ -28,17 +29,12 @@ namespace osu.Game.Screens.Ranking.Expanded.Accuracy
|
||||
/// </summary>
|
||||
public partial class AccuracyCircle : CompositeDrawable
|
||||
{
|
||||
private const double accuracy_x = 1;
|
||||
|
||||
private const double accuracy_s = 0.95;
|
||||
|
||||
private const double accuracy_a = 0.9;
|
||||
|
||||
private const double accuracy_b = 0.8;
|
||||
|
||||
private const double accuracy_c = 0.7;
|
||||
|
||||
private const double accuracy_d = 0;
|
||||
private static readonly double accuracy_x = ScoreProcessor.AccuracyCutoffFromRank(ScoreRank.X);
|
||||
private static readonly double accuracy_s = ScoreProcessor.AccuracyCutoffFromRank(ScoreRank.S);
|
||||
private static readonly double accuracy_a = ScoreProcessor.AccuracyCutoffFromRank(ScoreRank.A);
|
||||
private static readonly double accuracy_b = ScoreProcessor.AccuracyCutoffFromRank(ScoreRank.B);
|
||||
private static readonly double accuracy_c = ScoreProcessor.AccuracyCutoffFromRank(ScoreRank.C);
|
||||
private static readonly double accuracy_d = ScoreProcessor.AccuracyCutoffFromRank(ScoreRank.D);
|
||||
|
||||
/// <summary>
|
||||
/// Duration for the transforms causing this component to appear.
|
||||
|
Loading…
Reference in New Issue
Block a user