2021-10-29 13:32:31 +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;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
namespace osu.Game.Online.Solo
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A class specifically for sending scores to the API during score submission.
|
2021-12-10 15:01:41 +08:00
|
|
|
/// This is used instead of <see cref="APIScore"/> due to marginally different serialisation naming requirements.
|
2021-10-29 13:32:31 +08:00
|
|
|
/// </summary>
|
|
|
|
[Serializable]
|
|
|
|
public class SubmittableScore
|
|
|
|
{
|
|
|
|
[JsonProperty("rank")]
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
|
|
public ScoreRank Rank { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("total_score")]
|
|
|
|
public long TotalScore { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("accuracy")]
|
|
|
|
public double Accuracy { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty(@"pp")]
|
|
|
|
public double? PP { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("max_combo")]
|
|
|
|
public int MaxCombo { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("ruleset_id")]
|
|
|
|
public int RulesetID { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("passed")]
|
|
|
|
public bool Passed { get; set; }
|
|
|
|
|
|
|
|
// Used for API serialisation/deserialisation.
|
|
|
|
[JsonProperty("mods")]
|
|
|
|
public APIMod[] Mods { get; set; }
|
|
|
|
|
|
|
|
[JsonProperty("statistics")]
|
|
|
|
public Dictionary<HitResult, int> Statistics { get; set; }
|
|
|
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
public SubmittableScore()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public SubmittableScore(ScoreInfo score)
|
|
|
|
{
|
|
|
|
Rank = score.Rank;
|
|
|
|
TotalScore = score.TotalScore;
|
|
|
|
Accuracy = score.Accuracy;
|
|
|
|
PP = score.PP;
|
|
|
|
MaxCombo = score.MaxCombo;
|
|
|
|
RulesetID = score.RulesetID;
|
|
|
|
Passed = score.Passed;
|
|
|
|
Mods = score.APIMods;
|
|
|
|
Statistics = score.Statistics;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|