// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using System.Linq; using Newtonsoft.Json; using osu.Game.Online.API; using osu.Game.Online.API.Requests.Responses; using osu.Game.Rulesets.Scoring; namespace osu.Game.Scoring.Legacy { /// /// A minified version of retrofit onto the end of legacy replay files (.osr), /// containing the minimum data required to support storage of non-legacy replays. /// [Serializable] [JsonObject(MemberSerialization.OptIn)] public class LegacyReplaySoloScoreInfo { /// /// The value of this property should correspond to /// (i.e. come from the `solo_scores` ID scheme). /// [JsonProperty("online_id")] public long OnlineID { get; set; } = -1; [JsonProperty("mods")] public APIMod[] Mods { get; set; } = Array.Empty(); [JsonProperty("statistics")] public Dictionary Statistics { get; set; } = new Dictionary(); [JsonProperty("maximum_statistics")] public Dictionary MaximumStatistics { get; set; } = new Dictionary(); [JsonProperty("client_version")] public string ClientVersion = string.Empty; public static LegacyReplaySoloScoreInfo FromScore(ScoreInfo score) => new LegacyReplaySoloScoreInfo { OnlineID = score.OnlineID, Mods = score.APIMods, Statistics = score.Statistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value), MaximumStatistics = score.MaximumStatistics.Where(kvp => kvp.Value != 0).ToDictionary(kvp => kvp.Key, kvp => kvp.Value), ClientVersion = score.ClientVersion, }; } }