1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 16:37:26 +08:00
osu-lazer/osu.Game/Rulesets/Mods/ModExtensions.cs
Dean Herbert 7d74d84e6c Display mod icons using stable ordering
In discussion with nanaya, we likely want this now that we're adding the
ability for some icons to be extended. Historically mod icons have been
displayed in a stable but arbitrary order (based on their position in
the `Mods` enum).

This change aims to make them stable across lazer scores (where they are
stored based on .. the order the user selected them).
2023-09-28 16:48:09 +09:00

38 lines
1.3 KiB
C#

// 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.
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring;
namespace osu.Game.Rulesets.Mods
{
public static class ModExtensions
{
public static Score CreateScoreFromReplayData(this ICreateReplayData mod, IBeatmap beatmap, IReadOnlyList<Mod> mods)
{
var replayData = mod.CreateReplayData(beatmap, mods);
return new Score
{
Replay = replayData.Replay,
ScoreInfo =
{
User = new APIUser
{
Id = replayData.User.OnlineID,
Username = replayData.User.Username,
IsBot = replayData.User.IsBot,
}
}
};
}
public static IEnumerable<Mod> AsOrdered(this IEnumerable<Mod> mods) => mods
.OrderBy(m => m.Type)
.ThenBy(m => m.Acronym);
}
}