Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public class APIUserMatchmakingStatistics
public int Rating { get; set; }

[JsonProperty("rank")]
public int? Rank { get; set; }
public int Rank { get; set; }

[JsonProperty("rank_percent")]
public float RankPercent { get; set; }
Comment on lines +20 to +23

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see reference


[JsonProperty("plays")]
public int Plays { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Scoring;

namespace osu.Game.Overlays.Profile.Header.Components
{
Expand Down Expand Up @@ -107,32 +108,59 @@ private void updateDisplay()
return;
}

APIUserMatchmakingStatistics[] stats = User.Value.User.MatchmakingStatistics;
APIUserMatchmakingStatistics[] allStats = User.Value.User.MatchmakingStatistics;

if (stats.Length == 0)
if (allStats.Length == 0)
{
Hide();
return;
}

int? highestRank = null;
APIUserMatchmakingStatistics? highestRankStats = null;

foreach (var stat in stats)
foreach (var stats in allStats)
{
if (stat.Pool.Active && stat.Rank != null)
{
if (highestRank == null || stat.Rank < highestRank)
highestRank = stat.Rank;
}
if (stats.Pool.Active && (highestRankStats == null || stats.Rank < highestRankStats.Rank))
highestRankStats = stats;
}
Comment on lines +111 to 125

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see reference


rankText.Text = highestRank == null ? "-" : $"#{highestRank:N0}";
rankText.Text = highestRankStats == null ? "-" : $"#{highestRankStats.Rank:N0}";

if (highestRankStats != null)
rankText.Colour = OsuColour.ForRankingTier(GetRankingTier(highestRankStats));

TooltipContent = new MatchmakingStatsTooltipData(colourProvider, stats.OrderByDescending(s => s.PoolId).ToArray());
TooltipContent = new MatchmakingStatsTooltipData(colourProvider, allStats.OrderByDescending(s => s.PoolId).ToArray());

Show();
}

/// <seealso href="https://github.com/ppy/osu-web/blob/9f136df53a1c436229b0e4eb192011c15514dcf9/resources/js/profile-page/matchmaking.tsx#L15-L34"/>
public static RankingTier GetRankingTier(APIUserMatchmakingStatistics stats)
{
int rank = stats.Rank;
float percent = stats.RankPercent;

if (rank <= 100)
return RankingTier.Lustrous;

if (percent < 0.05)
return RankingTier.Radiant;

if (percent < 0.2)
return RankingTier.Rhodium;

if (percent < 0.5)
return RankingTier.Platinum;

if (percent < 0.75)
return RankingTier.Gold;

if (percent < 0.95)
return RankingTier.Silver;

return RankingTier.Bronze;
}

public ITooltip<MatchmakingStatsTooltipData> GetCustomTooltip() => new MatchmakingStatsTooltip();

public MatchmakingStatsTooltipData? TooltipContent { get; private set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,23 @@ public void SetContent(MatchmakingStatsTooltipData content)
};
}

private Drawable[] createRow(OverlayColourProvider colourProvider, APIUserMatchmakingStatistics stat)
private Drawable[] createRow(OverlayColourProvider colourProvider, APIUserMatchmakingStatistics stats)
{
return
[
new StatisticText(colourProvider)
{
Text = stat.Pool.Name,
Text = stats.Pool.Name,
Colour = Color4.White
},
new StatisticText(colourProvider) { Text = $"#{stat.Rank:N0}" },
new StatisticText(colourProvider) { Text = stat.FirstPlacements.ToString("N0") },
new StatisticText(colourProvider) { Text = stat.Plays.ToString("N0") },
new StatisticText(colourProvider) { Text = stat.Rating.ToString("N0") + (stat.IsRatingProvisional ? "*" : string.Empty) }
new StatisticText(colourProvider)
{
Text = $"#{stats.Rank:N0}",
Colour = OsuColour.ForRankingTier(MatchmakingStatsDisplay.GetRankingTier(stats))
},
new StatisticText(colourProvider) { Text = stats.FirstPlacements.ToString("N0") },
new StatisticText(colourProvider) { Text = stats.Plays.ToString("N0") },
new StatisticText(colourProvider) { Text = stats.Rating.ToString("N0") + (stats.IsRatingProvisional ? "*" : string.Empty) }
];
}

Expand Down
Loading