1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-25 15:00:44 +08:00

Floor star rating to 2 decimal places rather than rounding

Rounding semi-regularly confuses users who aim for star rating pass / FC
medals and then feel they have been cheated out of a medal because they
passed an "X-star beatmap", but the actual star rating of the beatmap is
slightly under X.

The latest instance of this can be found at
https://osu.ppy.sh/community/forums/topics/2091333?n=2. The relevant
beatmap there is https://osu.ppy.sh/beatmapsets/2162554#osu/4746232,
whose raw star rating is 6.9976070253117344.

The other direction would be to fix the star rating medals instead, but
I think this is more reasonable given we already do similar things to
accuracy displays.
This commit is contained in:
Bartłomiej Dach
2025-06-13 08:39:49 +02:00
Unverified
parent e258244caf
commit 4fd2a488b7
2 changed files with 23 additions and 1 deletions
@@ -21,5 +21,18 @@ namespace osu.Game.Tests.NonVisual
{
Assert.AreEqual(expectedOutput, input.FormatAccuracy().ToString());
}
[TestCase(3, "3.00")]
[TestCase(3.3, "3.30")]
[TestCase(3.55, "3.55")]
[TestCase(3.553, "3.55")]
[TestCase(3.557, "3.55")]
[TestCase(3.9999, "3.99")]
[TestCase(3.999999, "3.99")]
[TestCase(4, "4.00")]
public void TestStarRatingFormatting(double input, string expectedOutput)
{
Assert.AreEqual(expectedOutput, input.FormatStarRating().ToString());
}
}
}
+10 -1
View File
@@ -36,7 +36,16 @@ namespace osu.Game.Utils
/// Formats the supplied star rating in a consistent, simplified way.
/// </summary>
/// <param name="starRating">The star rating to be formatted.</param>
public static LocalisableString FormatStarRating(this double starRating) => starRating.ToLocalisableString("0.00");
public static LocalisableString FormatStarRating(this double starRating)
{
// for the sake of display purposes, we don't want to show a user a "rounded up" star rating to the next whole number.
// i.e. a beatmap which has a star rating of 6.9999* should never show as 7.00*.
// this matters for star rating medals which use hard cutoffs at whole numbers,
// which then confuses users when they beat a 6.9999* beatmap but don't get the 7-star medal.
starRating = Math.Floor(starRating * 100) / 100;
return starRating.ToLocalisableString("0.00");
}
/// <summary>
/// Finds the number of digits after the decimal.