2022-03-29 15:45:21 +08:00
|
|
|
// 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;
|
2023-09-28 15:47:41 +08:00
|
|
|
using System.Linq;
|
2022-03-29 15:45:21 +08:00
|
|
|
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
|
|
|
|
{
|
2023-08-30 05:28:50 +08:00
|
|
|
Id = replayData.User.OnlineID,
|
2022-03-29 15:45:21 +08:00
|
|
|
Username = replayData.User.Username,
|
2023-08-30 05:28:50 +08:00
|
|
|
IsBot = replayData.User.IsBot,
|
2022-03-29 15:45:21 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2023-09-28 15:47:41 +08:00
|
|
|
|
|
|
|
public static IEnumerable<Mod> AsOrdered(this IEnumerable<Mod> mods) => mods
|
|
|
|
.OrderBy(m => m.Type)
|
|
|
|
.ThenBy(m => m.Acronym);
|
2022-03-29 15:45:21 +08:00
|
|
|
}
|
|
|
|
}
|