2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-12-22 23:51:24 +08:00
|
|
|
|
using System;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2018-12-22 23:51:24 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2020-02-04 12:17:23 +08:00
|
|
|
|
using osu.Game.Utils;
|
2020-02-04 12:36:22 +08:00
|
|
|
|
using static osu.Game.Users.User;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Users
|
|
|
|
|
{
|
|
|
|
|
public class UserStatistics
|
|
|
|
|
{
|
2019-11-28 02:56:22 +08:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public User User;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"level")]
|
|
|
|
|
public LevelInfo Level;
|
|
|
|
|
|
|
|
|
|
public struct LevelInfo
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"current")]
|
|
|
|
|
public int Current;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"progress")]
|
|
|
|
|
public int Progress;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-17 13:50:48 +08:00
|
|
|
|
[JsonProperty(@"global_rank")]
|
|
|
|
|
public int? GlobalRank;
|
|
|
|
|
|
2021-02-18 20:37:52 +08:00
|
|
|
|
public int? CountryRank;
|
|
|
|
|
|
2021-02-16 12:28:51 +08:00
|
|
|
|
[JsonProperty(@"rank")]
|
2021-02-18 20:37:52 +08:00
|
|
|
|
private UserRanks ranks
|
|
|
|
|
{
|
|
|
|
|
// eventually that will also become an own json property instead of reading from a `rank` object.
|
|
|
|
|
// see https://github.com/ppy/osu-web/blob/cb79bb72186c8f1a25f6a6f5ef315123decb4231/app/Transformers/UserStatisticsTransformer.php#L53.
|
|
|
|
|
set => CountryRank = value.Country;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-02-16 12:28:51 +08:00
|
|
|
|
[JsonProperty(@"pp")]
|
|
|
|
|
public decimal? PP;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"ranked_score")]
|
|
|
|
|
public long RankedScore;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"hit_accuracy")]
|
|
|
|
|
public decimal Accuracy;
|
|
|
|
|
|
2020-02-03 23:09:07 +08:00
|
|
|
|
[JsonIgnore]
|
2020-02-04 12:17:23 +08:00
|
|
|
|
public string DisplayAccuracy => Accuracy.FormatAccuracy();
|
2020-02-03 23:09:07 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"play_count")]
|
|
|
|
|
public int PlayCount;
|
|
|
|
|
|
2018-12-22 23:51:24 +08:00
|
|
|
|
[JsonProperty(@"play_time")]
|
|
|
|
|
public int? PlayTime;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"total_score")]
|
|
|
|
|
public long TotalScore;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"total_hits")]
|
|
|
|
|
public int TotalHits;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"maximum_combo")]
|
|
|
|
|
public int MaxCombo;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"replays_watched_by_others")]
|
|
|
|
|
public int ReplaysWatched;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"grade_counts")]
|
|
|
|
|
public Grades GradesCount;
|
|
|
|
|
|
|
|
|
|
public struct Grades
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"ssh")]
|
2020-02-04 21:20:15 +08:00
|
|
|
|
public int? SSPlus;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"ss")]
|
|
|
|
|
public int SS;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"sh")]
|
2020-02-04 21:20:15 +08:00
|
|
|
|
public int? SPlus;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"s")]
|
|
|
|
|
public int S;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"a")]
|
|
|
|
|
public int A;
|
2018-12-22 23:51:24 +08:00
|
|
|
|
|
2020-02-05 02:02:10 +08:00
|
|
|
|
public int this[ScoreRank rank]
|
2018-12-22 23:51:24 +08:00
|
|
|
|
{
|
2019-03-06 15:30:56 +08:00
|
|
|
|
get
|
2018-12-22 23:51:24 +08:00
|
|
|
|
{
|
2019-03-06 15:30:56 +08:00
|
|
|
|
switch (rank)
|
|
|
|
|
{
|
|
|
|
|
case ScoreRank.XH:
|
2020-02-05 02:02:10 +08:00
|
|
|
|
return SSPlus ?? 0;
|
2019-05-07 12:23:09 +08:00
|
|
|
|
|
2019-03-06 15:30:56 +08:00
|
|
|
|
case ScoreRank.X:
|
|
|
|
|
return SS;
|
2019-05-07 12:23:09 +08:00
|
|
|
|
|
2019-03-06 15:30:56 +08:00
|
|
|
|
case ScoreRank.SH:
|
2020-02-05 02:02:10 +08:00
|
|
|
|
return SPlus ?? 0;
|
2019-05-07 12:23:09 +08:00
|
|
|
|
|
2019-03-06 15:30:56 +08:00
|
|
|
|
case ScoreRank.S:
|
|
|
|
|
return S;
|
2019-05-07 12:23:09 +08:00
|
|
|
|
|
2019-03-06 15:30:56 +08:00
|
|
|
|
case ScoreRank.A:
|
|
|
|
|
return A;
|
2019-05-07 12:23:09 +08:00
|
|
|
|
|
2019-03-06 15:30:56 +08:00
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentException($"API does not return {rank.ToString()}");
|
|
|
|
|
}
|
2018-12-22 23:51:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-02-18 20:37:52 +08:00
|
|
|
|
private struct UserRanks
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-02-18 20:55:45 +08:00
|
|
|
|
#pragma warning disable 649
|
2018-04-13 17:19:50 +08:00
|
|
|
|
[JsonProperty(@"country")]
|
|
|
|
|
public int? Country;
|
2021-02-18 20:55:45 +08:00
|
|
|
|
#pragma warning restore 649
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2019-08-04 19:35:26 +08:00
|
|
|
|
|
|
|
|
|
public RankHistoryData RankHistory;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|