1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:07:44 +08:00

Improve user ratings calculations to make more sense

Closes #1552.
This commit is contained in:
Dean Herbert 2017-11-23 18:09:42 +09:00
parent b0b3c9167e
commit d93911ae97
3 changed files with 14 additions and 7 deletions

View File

@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps
public class BeatmapMetrics
{
/// <summary>
/// Total vote counts of user ratings on a scale of 0..length.
/// Total vote counts of user ratings on a scale of 0..10 where 0 is unused (probably will be fixed at API?).
/// </summary>
public IEnumerable<int> Ratings { get; set; }

View File

@ -20,6 +20,7 @@ namespace osu.Game.Graphics.UserInterface
private const Easing easing = Easing.InOutCubic;
private float length;
/// <summary>
/// Length of the bar, ranges from 0 to 1
/// </summary>

View File

@ -29,11 +29,17 @@ namespace osu.Game.Screens.Select.Details
if (value == metrics) return;
metrics = value;
var ratings = Metrics.Ratings.ToList();
negativeRatings.Text = ratings.GetRange(0, ratings.Count / 2 + 1).Sum().ToString();
positiveRatings.Text = ratings.GetRange(ratings.Count / 2 + 1, ratings.Count / 2).Sum().ToString();
ratingsBar.Length = (float)ratings.GetRange(0, ratings.Count / 2 + 1).Sum() / ratings.Sum();
graph.Values = Metrics.Ratings.Select(r => (float)r);
const int rating_range = 10;
var ratings = Metrics.Ratings.ToList().GetRange(1, rating_range); // adjust for API returning weird empty data at 0.
var negativeCount = ratings.GetRange(0, rating_range / 2).Sum();
var totalCount = ratings.Sum();
negativeRatings.Text = negativeCount.ToString();
positiveRatings.Text = (totalCount - negativeCount).ToString();
ratingsBar.Length = (float)negativeCount / totalCount;
graph.Values = ratings.GetRange(0, rating_range).Select(r => (float)r);
}
}