From 90b0f035ad79cee0fb7edb995e8b37d9317c02bd Mon Sep 17 00:00:00 2001 From: Alex Amadori Date: Fri, 24 Feb 2017 17:01:14 +0100 Subject: [PATCH] Compute average of star ratings --- osu.Game/Screens/Select/CarouselContainer.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Select/CarouselContainer.cs b/osu.Game/Screens/Select/CarouselContainer.cs index 0e540d8868..dea9125b74 100644 --- a/osu.Game/Screens/Select/CarouselContainer.cs +++ b/osu.Game/Screens/Select/CarouselContainer.cs @@ -206,11 +206,20 @@ namespace osu.Game.Screens.Select case FilterControl.SortMode.Difficulty: groups.Sort((x, y) => { - /*TODO: replace with star rating once implemented - * Assumes BeatmapSets not to be grouped - or to be by difficulty, - * otherwise this sorting makes little sense - or does it? */ - if (x.BeatmapSet.Beatmaps.First().StarDifficulty > - y.BeatmapSet.Beatmaps.First().StarDifficulty) + float x_average=0, y_average=0; + int counter=0; + foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps) { + x_average += set.StarDifficulty; + counter++; + } + x_average /= counter; + counter = 0; + foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps) { + y_average += set.StarDifficulty; + counter++; + } + y_average /= counter; + if (x_average > y_average) return 1; else return -1;