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}",
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",
});
@ -199,7 +205,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
Username = "User 0",
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",
});

View File

@ -165,7 +165,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
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;
userStateDisplay.UpdateStatus(User.State, User.BeatmapAvailability);

View File

@ -3,7 +3,6 @@
using System;
using Newtonsoft.Json;
using osu.Game.Online.API.Requests;
using osu.Game.Scoring;
using osu.Game.Utils;
using static osu.Game.Users.User;
@ -27,24 +26,22 @@ namespace osu.Game.Users
public int Progress;
}
/// <remarks>
/// This must only be used when coming from condensed user responses (e.g. from <see cref="GetUsersRequest"/>), otherwise use <code>Ranks.Global</code>.
/// </remarks>
// todo: this should likely be moved to a separate UserStatisticsCompact class at some point.
[JsonProperty(@"rank")]
public UserRanks Ranks;
// 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")]
public int? GlobalRank;
[JsonProperty(@"pp")]
public decimal? PP;
[JsonProperty(@"pp_rank")] // the API sometimes only returns this value in condensed user responses
private int? rank
private int? globalRank
{
set => Ranks.Global = value;
}
[JsonProperty(@"rank")]
public UserRanks Ranks;
[JsonProperty(@"pp")]
public decimal? PP;
[JsonProperty(@"pp_rank")]
public int PPRank;
[JsonProperty(@"ranked_score")]
public long RankedScore;