mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 17:52:56 +08:00
Move GetDifficultyRating
helper method to StarDifficulty
This commit is contained in:
parent
b068df2149
commit
ef258122d2
@ -157,7 +157,7 @@ namespace osu.Game.Tests.Beatmaps
|
||||
[TestCase(8.3, DifficultyRating.ExpertPlus)]
|
||||
public void TestDifficultyRatingMapping(double starRating, DifficultyRating expectedBracket)
|
||||
{
|
||||
var actualBracket = BeatmapDifficultyCache.GetDifficultyRating(starRating);
|
||||
var actualBracket = StarDifficulty.GetDifficultyRating(starRating);
|
||||
|
||||
Assert.AreEqual(expectedBracket, actualBracket);
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ using osu.Framework.Extensions;
|
||||
using osu.Framework.Lists;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets;
|
||||
@ -165,34 +164,6 @@ namespace osu.Game.Beatmaps
|
||||
updateScheduler);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="DifficultyRating"/> that describes a star rating.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For more information, see: https://osu.ppy.sh/help/wiki/Difficulties
|
||||
/// </remarks>
|
||||
/// <param name="starRating">The star rating.</param>
|
||||
/// <returns>The <see cref="DifficultyRating"/> that best describes <paramref name="starRating"/>.</returns>
|
||||
public static DifficultyRating GetDifficultyRating(double starRating)
|
||||
{
|
||||
if (Precision.AlmostBigger(starRating, 6.5, 0.005))
|
||||
return DifficultyRating.ExpertPlus;
|
||||
|
||||
if (Precision.AlmostBigger(starRating, 5.3, 0.005))
|
||||
return DifficultyRating.Expert;
|
||||
|
||||
if (Precision.AlmostBigger(starRating, 4.0, 0.005))
|
||||
return DifficultyRating.Insane;
|
||||
|
||||
if (Precision.AlmostBigger(starRating, 2.7, 0.005))
|
||||
return DifficultyRating.Hard;
|
||||
|
||||
if (Precision.AlmostBigger(starRating, 2.0, 0.005))
|
||||
return DifficultyRating.Normal;
|
||||
|
||||
return DifficultyRating.Easy;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates all tracked <see cref="BindableStarDifficulty"/> using the current ruleset and mods.
|
||||
/// </summary>
|
||||
|
@ -128,7 +128,7 @@ namespace osu.Game.Beatmaps
|
||||
public List<EFScoreInfo> Scores { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public DifficultyRating DifficultyRating => BeatmapDifficultyCache.GetDifficultyRating(StarRating);
|
||||
public DifficultyRating DifficultyRating => StarDifficulty.GetDifficultyRating(StarRating);
|
||||
|
||||
public override string ToString() => this.GetDisplayTitle();
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#nullable disable
|
||||
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
@ -50,6 +51,34 @@ namespace osu.Game.Beatmaps
|
||||
Attributes = null;
|
||||
}
|
||||
|
||||
public DifficultyRating DifficultyRating => BeatmapDifficultyCache.GetDifficultyRating(Stars);
|
||||
public DifficultyRating DifficultyRating => GetDifficultyRating(Stars);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the <see cref="DifficultyRating"/> that describes a star rating.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// For more information, see: https://osu.ppy.sh/help/wiki/Difficulties
|
||||
/// </remarks>
|
||||
/// <param name="starRating">The star rating.</param>
|
||||
/// <returns>The <see cref="DifficultyRating"/> that best describes <paramref name="starRating"/>.</returns>
|
||||
public static DifficultyRating GetDifficultyRating(double starRating)
|
||||
{
|
||||
if (Precision.AlmostBigger(starRating, 6.5, 0.005))
|
||||
return DifficultyRating.ExpertPlus;
|
||||
|
||||
if (Precision.AlmostBigger(starRating, 5.3, 0.005))
|
||||
return DifficultyRating.Expert;
|
||||
|
||||
if (Precision.AlmostBigger(starRating, 4.0, 0.005))
|
||||
return DifficultyRating.Insane;
|
||||
|
||||
if (Precision.AlmostBigger(starRating, 2.7, 0.005))
|
||||
return DifficultyRating.Hard;
|
||||
|
||||
if (Precision.AlmostBigger(starRating, 2.0, 0.005))
|
||||
return DifficultyRating.Normal;
|
||||
|
||||
return DifficultyRating.Easy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Screens.Edit.Verify
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InterpretedDifficulty.Default = BeatmapDifficultyCache.GetDifficultyRating(EditorBeatmap.BeatmapInfo.StarRating);
|
||||
InterpretedDifficulty.Default = StarDifficulty.GetDifficultyRating(EditorBeatmap.BeatmapInfo.StarRating);
|
||||
InterpretedDifficulty.SetDefault();
|
||||
|
||||
Child = new Container
|
||||
|
Loading…
Reference in New Issue
Block a user