mirror of
https://github.com/ppy/osu.git
synced 2024-11-08 02:59:48 +08:00
39 lines
1.5 KiB
C#
39 lines
1.5 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;
|
|
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
|
|
{
|
|
/// <summary>
|
|
/// A minified version of <see cref="SoloScoreInfo"/> retrofit onto the end of legacy replay files (.osr),
|
|
/// containing the minimum data required to support storage of non-legacy replays.
|
|
/// </summary>
|
|
[Serializable]
|
|
[JsonObject(MemberSerialization.OptIn)]
|
|
public class LegacyReplaySoloScoreInfo
|
|
{
|
|
[JsonProperty("mods")]
|
|
public APIMod[] Mods { get; set; } = Array.Empty<APIMod>();
|
|
|
|
[JsonProperty("statistics")]
|
|
public Dictionary<HitResult, int> Statistics { get; set; } = new Dictionary<HitResult, int>();
|
|
|
|
[JsonProperty("maximum_statistics")]
|
|
public Dictionary<HitResult, int> MaximumStatistics { get; set; } = new Dictionary<HitResult, int>();
|
|
|
|
public static LegacyReplaySoloScoreInfo FromScore(ScoreInfo score) => new LegacyReplaySoloScoreInfo
|
|
{
|
|
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),
|
|
};
|
|
}
|
|
}
|