mirror of https://github.com/ppy/osu
Always use JSON property `global_rank` for global ranks instead
This commit is contained in:
parent
5b4999e8af
commit
0e7f52b5cc
|
@ -158,7 +158,13 @@ public void TestManyUsers()
|
|||
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 @@ public void TestUserWithMods()
|
|||
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",
|
||||
});
|
||||
|
|
|
@ -165,7 +165,7 @@ protected override void OnRoomUpdated()
|
|||
|
||||
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);
|
||||
|
|
|
@ -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 @@ public struct LevelInfo
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue