mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 14:52:55 +08:00
Fix very high accuracies feigning as "perfect" 100% plays when actually below
This commit is contained in:
parent
aca3cd85c9
commit
cb4ae6e61a
@ -42,7 +42,7 @@ namespace osu.Game.Users
|
|||||||
public long RankedScore;
|
public long RankedScore;
|
||||||
|
|
||||||
[JsonProperty(@"hit_accuracy")]
|
[JsonProperty(@"hit_accuracy")]
|
||||||
public decimal Accuracy;
|
public double Accuracy;
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string DisplayAccuracy => Accuracy.FormatAccuracy();
|
public string DisplayAccuracy => Accuracy.FormatAccuracy();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
|
|
||||||
namespace osu.Game.Utils
|
namespace osu.Game.Utils
|
||||||
@ -12,14 +13,14 @@ namespace osu.Game.Utils
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="accuracy">The accuracy to be formatted</param>
|
/// <param name="accuracy">The accuracy to be formatted</param>
|
||||||
/// <returns>formatted accuracy in percentage</returns>
|
/// <returns>formatted accuracy in percentage</returns>
|
||||||
public static string FormatAccuracy(this double accuracy) => $"{accuracy:0.00%}";
|
public static string FormatAccuracy(this double accuracy)
|
||||||
|
{
|
||||||
|
// we don't ever want to show 100% when the accuracy is below perfect, even if it rounds to 100%.
|
||||||
|
if (accuracy < 1 && accuracy > 0.9999)
|
||||||
|
accuracy = 0.9999;
|
||||||
|
|
||||||
/// <summary>
|
return $"{accuracy:0.00%}";
|
||||||
/// Turns the provided accuracy into a percentage with 2 decimal places.
|
}
|
||||||
/// </summary>
|
|
||||||
/// <param name="accuracy">The accuracy to be formatted</param>
|
|
||||||
/// <returns>formatted accuracy in percentage</returns>
|
|
||||||
public static string FormatAccuracy(this decimal accuracy) => $"{accuracy:0.00}%";
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Formats the supplied rank/leaderboard position in a consistent, simplified way.
|
/// Formats the supplied rank/leaderboard position in a consistent, simplified way.
|
||||||
|
Loading…
Reference in New Issue
Block a user