Always use JSON property global_rank for global ranks instead

This commit is contained in:
Salman Ahmed 2021-02-16 07:28:51 +03:00
parent 5b4999e8af
commit 0e7f52b5cc
3 changed files with 26 additions and 17 deletions

View File

@ -158,7 +158,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
Username = $"User {i}", Username = $"User {i}",
RulesetsStatistics = new Dictionary<string, UserStatistics> RulesetsStatistics = new Dictionary<string, UserStatistics>
{ {
{ Ruleset.Value.ShortName, new UserStatistics { GlobalRank = RNG.Next(1, 100000) } } {
Ruleset.Value.ShortName,
new UserStatistics
{
Ranks = new UserStatistics.UserRanks { Global = RNG.Next(1, 100000) }
}
}
}, },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
}); });
@ -199,7 +205,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
Username = "User 0", Username = "User 0",
RulesetsStatistics = new Dictionary<string, UserStatistics> RulesetsStatistics = new Dictionary<string, UserStatistics>
{ {
{ Ruleset.Value.ShortName, new UserStatistics { GlobalRank = RNG.Next(1, 100000) } } {
Ruleset.Value.ShortName,
new UserStatistics
{
Ranks = new UserStatistics.UserRanks { Global = RNG.Next(1, 100000) }
}
}
}, },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg", CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
}); });

View File

@ -165,7 +165,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
var ruleset = rulesets.GetRuleset(Room.Settings.RulesetID); var ruleset = rulesets.GetRuleset(Room.Settings.RulesetID);
var currentModeRank = User.User?.RulesetsStatistics?.GetValueOrDefault(ruleset.ShortName)?.GlobalRank; var currentModeRank = User.User?.RulesetsStatistics?.GetValueOrDefault(ruleset.ShortName)?.Ranks.Global;
userRankText.Text = currentModeRank != null ? $"#{currentModeRank.Value:N0}" : string.Empty; userRankText.Text = currentModeRank != null ? $"#{currentModeRank.Value:N0}" : string.Empty;
userStateDisplay.UpdateStatus(User.State, User.BeatmapAvailability); userStateDisplay.UpdateStatus(User.State, User.BeatmapAvailability);

View File

@ -3,7 +3,6 @@
using System; using System;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Game.Online.API.Requests;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Utils; using osu.Game.Utils;
using static osu.Game.Users.User; using static osu.Game.Users.User;
@ -27,24 +26,22 @@ namespace osu.Game.Users
public int Progress; public int Progress;
} }
/// <remarks> [JsonProperty(@"rank")]
/// This must only be used when coming from condensed user responses (e.g. from <see cref="GetUsersRequest"/>), otherwise use <code>Ranks.Global</code>. public UserRanks Ranks;
/// </remarks>
// todo: this should likely be moved to a separate UserStatisticsCompact class at some point. // eventually UserRanks object will be completely replaced with separate global and country rank properties, see https://github.com/ppy/osu-web/blob/cb79bb72186c8f1a25f6a6f5ef315123decb4231/app/Transformers/UserStatisticsTransformer.php#L53.
// but for now, always point UserRanks.Global to the global_rank property, as that is included solely for requests like GetUsersRequest.
[JsonProperty(@"global_rank")] [JsonProperty(@"global_rank")]
public int? GlobalRank; private int? globalRank
[JsonProperty(@"pp")]
public decimal? PP;
[JsonProperty(@"pp_rank")] // the API sometimes only returns this value in condensed user responses
private int? rank
{ {
set => Ranks.Global = value; set => Ranks.Global = value;
} }
[JsonProperty(@"rank")] [JsonProperty(@"pp")]
public UserRanks Ranks; public decimal? PP;
[JsonProperty(@"pp_rank")]
public int PPRank;
[JsonProperty(@"ranked_score")] [JsonProperty(@"ranked_score")]
public long RankedScore; public long RankedScore;