mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Remove necessity of using CurrentModeRank
as a fallback
This commit is contained in:
parent
90aa6256d7
commit
a1496cd8f3
@ -155,7 +155,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
Id = i,
|
||||
Username = $"User {i}",
|
||||
CurrentModeRank = RNG.Next(1, 100000),
|
||||
AllStatistics =
|
||||
{
|
||||
{ Ruleset.Value, new UserStatistics { GlobalRank = RNG.Next(1, 100000) } }
|
||||
},
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
});
|
||||
|
||||
@ -193,7 +196,10 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
{
|
||||
Id = 0,
|
||||
Username = "User 0",
|
||||
CurrentModeRank = RNG.Next(1, 100000),
|
||||
AllStatistics =
|
||||
{
|
||||
{ Ruleset.Value, new UserStatistics { GlobalRank = RNG.Next(1, 100000) } }
|
||||
},
|
||||
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg",
|
||||
});
|
||||
|
||||
|
@ -165,10 +165,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
|
||||
var ruleset = rulesets.GetRuleset(Room.Settings.RulesetID);
|
||||
|
||||
var currentModeRank = User.User?.GetStatisticsFor(ruleset)?.GlobalRank;
|
||||
|
||||
// fallback to current mode rank for testing purposes.
|
||||
currentModeRank ??= User.User?.CurrentModeRank;
|
||||
|
||||
userRankText.Text = currentModeRank != null ? $"#{currentModeRank.Value:N0}" : string.Empty;
|
||||
|
||||
userStateDisplay.UpdateStatus(User.State, User.BeatmapAvailability);
|
||||
|
@ -243,7 +243,10 @@ namespace osu.Game.Users
|
||||
[JsonExtensionData]
|
||||
private readonly IDictionary<string, JToken> otherProperties = new Dictionary<string, JToken>();
|
||||
|
||||
private readonly Dictionary<RulesetInfo, UserStatistics> statisticsCache = new Dictionary<RulesetInfo, UserStatistics>();
|
||||
/// <summary>
|
||||
/// Map for ruleset with their associated user statistics, can be altered for testing purposes.
|
||||
/// </summary>
|
||||
internal readonly Dictionary<RulesetInfo, UserStatistics> AllStatistics = new Dictionary<RulesetInfo, UserStatistics>();
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the user statistics for a certain ruleset.
|
||||
@ -254,10 +257,10 @@ namespace osu.Game.Users
|
||||
// todo: this should likely be moved to a separate UserCompact class at some point.
|
||||
public UserStatistics GetStatisticsFor(RulesetInfo ruleset)
|
||||
{
|
||||
if (statisticsCache.TryGetValue(ruleset, out var existing))
|
||||
if (AllStatistics.TryGetValue(ruleset, out var existing))
|
||||
return existing;
|
||||
|
||||
return statisticsCache[ruleset] = parseStatisticsFor(ruleset);
|
||||
return AllStatistics[ruleset] = parseStatisticsFor(ruleset);
|
||||
}
|
||||
|
||||
private UserStatistics parseStatisticsFor(RulesetInfo ruleset)
|
||||
|
Loading…
Reference in New Issue
Block a user