1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 22:42:57 +08:00

Change difficulty sort to be based on MaxStarDifficulty.

This commit is contained in:
Dean Herbert 2017-03-16 13:59:23 +09:00
parent 360340c61d
commit 4d84bf7350
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
2 changed files with 4 additions and 22 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using SQLite.Net.Attributes;
using SQLiteNetExtensions.Attributes;
@ -23,6 +24,8 @@ namespace osu.Game.Database
[OneToMany(CascadeOperations = CascadeOperation.All)]
public List<BeatmapInfo> Beatmaps { get; set; }
public float MaxStarDifficulty => Beatmaps.Max(b => b.StarDifficulty);
public bool DeletePending { get; set; }
public string Hash { get; set; }

View File

@ -173,28 +173,7 @@ namespace osu.Game.Screens.Select
sortedGroups.Sort((x, y) => string.Compare(x.BeatmapSet.Metadata.Author, y.BeatmapSet.Metadata.Author, StringComparison.InvariantCultureIgnoreCase));
break;
case SortMode.Difficulty:
sortedGroups.Sort((x, y) =>
{
float xAverage = 0, yAverage = 0;
int counter = 0;
foreach (BeatmapInfo set in x.BeatmapSet.Beatmaps)
{
xAverage += set.StarDifficulty;
counter++;
}
xAverage /= counter;
counter = 0;
foreach (BeatmapInfo set in y.BeatmapSet.Beatmaps)
{
yAverage += set.StarDifficulty;
counter++;
}
yAverage /= counter;
if (xAverage > yAverage)
return 1;
else
return -1;
});
sortedGroups.Sort((x, y) => x.BeatmapSet.MaxStarDifficulty.CompareTo(y.BeatmapSet.MaxStarDifficulty));
break;
default:
Sort(SortMode.Artist); // Temporary