mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 06:07:11 +09:00
Replace tournament player storage type with lightweight model
This commit is contained in:
@ -22,7 +22,6 @@ using osu.Game.Tournament.IO;
|
||||
using osu.Game.Tournament.IPC;
|
||||
using osu.Game.Tournament.Models;
|
||||
using osuTK.Input;
|
||||
using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
||||
|
||||
namespace osu.Game.Tournament
|
||||
{
|
||||
@ -187,9 +186,7 @@ namespace osu.Game.Tournament
|
||||
{
|
||||
var playersRequiringPopulation = ladder.Teams
|
||||
.SelectMany(t => t.Players)
|
||||
.Where(p => string.IsNullOrEmpty(p.Username)
|
||||
|| p.Statistics?.GlobalRank == null
|
||||
|| p.Statistics?.CountryRank == null).ToList();
|
||||
.Where(p => string.IsNullOrEmpty(p.Username) || p.Rank == null).ToList();
|
||||
|
||||
if (playersRequiringPopulation.Count == 0)
|
||||
return false;
|
||||
@ -197,7 +194,7 @@ namespace osu.Game.Tournament
|
||||
for (int i = 0; i < playersRequiringPopulation.Count; i++)
|
||||
{
|
||||
var p = playersRequiringPopulation[i];
|
||||
PopulateUser(p, immediate: true);
|
||||
PopulatePlayer(p, immediate: true);
|
||||
updateLoadProgressMessage($"Populating user stats ({i} / {playersRequiringPopulation.Count})");
|
||||
}
|
||||
|
||||
@ -259,9 +256,9 @@ namespace osu.Game.Tournament
|
||||
|
||||
private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s);
|
||||
|
||||
public void PopulateUser(APIUser user, Action success = null, Action failure = null, bool immediate = false)
|
||||
public void PopulatePlayer(TournamentPlayer player, Action success = null, Action failure = null, bool immediate = false)
|
||||
{
|
||||
var req = new GetUserRequest(user.Id, ladder.Ruleset.Value);
|
||||
var req = new GetUserRequest(player.Id, ladder.Ruleset.Value);
|
||||
|
||||
if (immediate)
|
||||
{
|
||||
@ -273,7 +270,7 @@ namespace osu.Game.Tournament
|
||||
req.Success += res => { populate(); };
|
||||
req.Failure += _ =>
|
||||
{
|
||||
user.Id = 1;
|
||||
player.Id = 1;
|
||||
failure?.Invoke();
|
||||
};
|
||||
|
||||
@ -287,12 +284,12 @@ namespace osu.Game.Tournament
|
||||
if (res == null)
|
||||
return;
|
||||
|
||||
user.Id = res.Id;
|
||||
player.Id = res.Id;
|
||||
|
||||
user.Username = res.Username;
|
||||
user.Statistics = res.Statistics;
|
||||
user.Country = res.Country;
|
||||
user.Cover = res.Cover;
|
||||
player.Username = res.Username;
|
||||
player.CoverUrl = res.CoverUrl;
|
||||
player.Country = res.Country;
|
||||
player.Rank = res.Statistics?.GlobalRank;
|
||||
|
||||
success?.Invoke();
|
||||
}
|
||||
|
Reference in New Issue
Block a user