2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2018-12-22 15:51:24 +00:00
|
|
|
|
using System;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using Newtonsoft.Json;
|
2018-12-22 15:51:24 +00:00
|
|
|
|
using osu.Game.Scoring;
|
2020-02-04 04:17:23 +00:00
|
|
|
|
using osu.Game.Utils;
|
2020-02-04 04:36:22 +00:00
|
|
|
|
using static osu.Game.Users.User;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Users
|
|
|
|
|
{
|
|
|
|
|
public class UserStatistics
|
|
|
|
|
{
|
2019-11-27 18:56:22 +00:00
|
|
|
|
[JsonProperty]
|
|
|
|
|
public User User;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
[JsonProperty(@"level")]
|
|
|
|
|
public LevelInfo Level;
|
|
|
|
|
|
|
|
|
|
public struct LevelInfo
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"current")]
|
|
|
|
|
public int Current;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"progress")]
|
|
|
|
|
public int Progress;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"pp")]
|
|
|
|
|
public decimal? PP;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"pp_rank")] // the API sometimes only returns this value in condensed user responses
|
2020-02-04 13:20:15 +00:00
|
|
|
|
private int? rank
|
2019-02-28 04:31:40 +00:00
|
|
|
|
{
|
|
|
|
|
set => Ranks.Global = value;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"rank")]
|
|
|
|
|
public UserRanks Ranks;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"ranked_score")]
|
|
|
|
|
public long RankedScore;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"hit_accuracy")]
|
|
|
|
|
public decimal Accuracy;
|
|
|
|
|
|
2020-02-03 15:09:07 +00:00
|
|
|
|
[JsonIgnore]
|
2020-02-04 04:17:23 +00:00
|
|
|
|
public string DisplayAccuracy => Accuracy.FormatAccuracy();
|
2020-02-03 15:09:07 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
[JsonProperty(@"play_count")]
|
|
|
|
|
public int PlayCount;
|
|
|
|
|
|
2018-12-22 15:51:24 +00:00
|
|
|
|
[JsonProperty(@"play_time")]
|
|
|
|
|
public int? PlayTime;
|
|
|
|
|
|
2018-04-13 09:19:50 +00: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 13:20:15 +00:00
|
|
|
|
public int? SSPlus;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"ss")]
|
|
|
|
|
public int SS;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"sh")]
|
2020-02-04 13:20:15 +00:00
|
|
|
|
public int? SPlus;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
[JsonProperty(@"s")]
|
|
|
|
|
public int S;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"a")]
|
|
|
|
|
public int A;
|
2018-12-22 15:51:24 +00:00
|
|
|
|
|
2020-02-04 18:02:10 +00:00
|
|
|
|
public int this[ScoreRank rank]
|
2018-12-22 15:51:24 +00:00
|
|
|
|
{
|
2019-03-06 07:30:56 +00:00
|
|
|
|
get
|
2018-12-22 15:51:24 +00:00
|
|
|
|
{
|
2019-03-06 07:30:56 +00:00
|
|
|
|
switch (rank)
|
|
|
|
|
{
|
|
|
|
|
case ScoreRank.XH:
|
2020-02-04 18:02:10 +00:00
|
|
|
|
return SSPlus ?? 0;
|
2019-05-07 04:23:09 +00:00
|
|
|
|
|
2019-03-06 07:30:56 +00:00
|
|
|
|
case ScoreRank.X:
|
|
|
|
|
return SS;
|
2019-05-07 04:23:09 +00:00
|
|
|
|
|
2019-03-06 07:30:56 +00:00
|
|
|
|
case ScoreRank.SH:
|
2020-02-04 18:02:10 +00:00
|
|
|
|
return SPlus ?? 0;
|
2019-05-07 04:23:09 +00:00
|
|
|
|
|
2019-03-06 07:30:56 +00:00
|
|
|
|
case ScoreRank.S:
|
|
|
|
|
return S;
|
2019-05-07 04:23:09 +00:00
|
|
|
|
|
2019-03-06 07:30:56 +00:00
|
|
|
|
case ScoreRank.A:
|
|
|
|
|
return A;
|
2019-05-07 04:23:09 +00:00
|
|
|
|
|
2019-03-06 07:30:56 +00:00
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentException($"API does not return {rank.ToString()}");
|
|
|
|
|
}
|
2018-12-22 15:51:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public struct UserRanks
|
|
|
|
|
{
|
|
|
|
|
[JsonProperty(@"global")]
|
|
|
|
|
public int? Global;
|
|
|
|
|
|
|
|
|
|
[JsonProperty(@"country")]
|
|
|
|
|
public int? Country;
|
|
|
|
|
}
|
2019-08-04 11:35:26 +00:00
|
|
|
|
|
|
|
|
|
public RankHistoryData RankHistory;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|