1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:33:20 +08:00

TournamentPlayer -> TournamentUser

This commit is contained in:
Salman Ahmed 2022-06-18 02:33:26 +03:00
parent 60903be566
commit 4c47996130
8 changed files with 48 additions and 48 deletions

View File

@ -25,13 +25,13 @@ namespace osu.Game.Tournament.Tests.Components
FullName = { Value = "Australia" }, FullName = { Value = "Australia" },
Players = Players =
{ {
new TournamentPlayer { Username = "ASecretBox" }, new TournamentUser { Username = "ASecretBox" },
new TournamentPlayer { Username = "Dereban" }, new TournamentUser { Username = "Dereban" },
new TournamentPlayer { Username = "mReKk" }, new TournamentUser { Username = "mReKk" },
new TournamentPlayer { Username = "uyghti" }, new TournamentUser { Username = "uyghti" },
new TournamentPlayer { Username = "Parkes" }, new TournamentUser { Username = "Parkes" },
new TournamentPlayer { Username = "Shiroha" }, new TournamentUser { Username = "Shiroha" },
new TournamentPlayer { Username = "Jordan The Bear" }, new TournamentUser { Username = "Jordan The Bear" },
} }
}; };

View File

@ -27,13 +27,13 @@ namespace osu.Game.Tournament.Tests.Components
Colour = "f2ca34" Colour = "f2ca34"
}; };
private readonly TournamentPlayer redPlayer = new TournamentPlayer private readonly TournamentUser redUser = new TournamentUser
{ {
Username = "BanchoBot", Username = "BanchoBot",
OnlineID = 3, OnlineID = 3,
}; };
private readonly TournamentPlayer bluePlayer = new TournamentPlayer private readonly TournamentUser blueUser = new TournamentUser
{ {
Username = "Zallius", Username = "Zallius",
OnlineID = 4, OnlineID = 4,
@ -59,11 +59,11 @@ namespace osu.Game.Tournament.Tests.Components
{ {
Team1 = Team1 =
{ {
Value = new TournamentTeam { Players = new BindableList<TournamentPlayer> { redPlayer } } Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
}, },
Team2 = Team2 =
{ {
Value = new TournamentTeam { Players = new BindableList<TournamentPlayer> { bluePlayer } } Value = new TournamentTeam { Players = new BindableList<TournamentUser> { blueUser } }
} }
}; };
@ -82,19 +82,19 @@ namespace osu.Game.Tournament.Tests.Components
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId()) AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
{ {
Sender = redPlayer.ToUser(), Sender = redUser.ToAPIUser(),
Content = "I am team red." Content = "I am team red."
})); }));
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId()) AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
{ {
Sender = redPlayer.ToUser(), Sender = redUser.ToAPIUser(),
Content = "I plan to win!" Content = "I plan to win!"
})); }));
AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(nextMessageId()) AddStep("message from team blue", () => testChannel.AddNewMessages(new Message(nextMessageId())
{ {
Sender = bluePlayer.ToUser(), Sender = blueUser.ToAPIUser(),
Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand." Content = "Not on my watch. Prepare to eat saaaaaaaaaand. Lots and lots of saaaaaaand."
})); }));

View File

@ -121,11 +121,11 @@ namespace osu.Game.Tournament.Tests
}, },
Players = Players =
{ {
new TournamentPlayer { Username = "Hello", Rank = 12 }, new TournamentUser { Username = "Hello", Rank = 12 },
new TournamentPlayer { Username = "Hello", Rank = 16 }, new TournamentUser { Username = "Hello", Rank = 16 },
new TournamentPlayer { Username = "Hello", Rank = 20 }, new TournamentUser { Username = "Hello", Rank = 20 },
new TournamentPlayer { Username = "Hello", Rank = 24 }, new TournamentUser { Username = "Hello", Rank = 24 },
new TournamentPlayer { Username = "Hello", Rank = 30 }, new TournamentUser { Username = "Hello", Rank = 30 },
} }
} }
}, },
@ -138,11 +138,11 @@ namespace osu.Game.Tournament.Tests
FullName = { Value = "United States" }, FullName = { Value = "United States" },
Players = Players =
{ {
new TournamentPlayer { Username = "Hello" }, new TournamentUser { Username = "Hello" },
new TournamentPlayer { Username = "Hello" }, new TournamentUser { Username = "Hello" },
new TournamentPlayer { Username = "Hello" }, new TournamentUser { Username = "Hello" },
new TournamentPlayer { Username = "Hello" }, new TournamentUser { Username = "Hello" },
new TournamentPlayer { Username = "Hello" }, new TournamentUser { Username = "Hello" },
} }
} }
}, },

View File

@ -55,7 +55,7 @@ namespace osu.Game.Tournament.Components
}, },
}; };
TournamentSpriteText createPlayerText(TournamentPlayer p) => TournamentSpriteText createPlayerText(TournamentUser p) =>
new TournamentSpriteText new TournamentSpriteText
{ {
Text = p.Username, Text = p.Username,

View File

@ -58,7 +58,7 @@ namespace osu.Game.Tournament.Models
}; };
[JsonProperty] [JsonProperty]
public BindableList<TournamentPlayer> Players { get; set; } = new BindableList<TournamentPlayer>(); public BindableList<TournamentUser> Players { get; set; } = new BindableList<TournamentUser>();
public TournamentTeam() public TournamentTeam()
{ {

View File

@ -9,10 +9,10 @@ using osu.Game.Users;
namespace osu.Game.Tournament.Models namespace osu.Game.Tournament.Models
{ {
/// <summary> /// <summary>
/// A tournament player, containing simple information about the player. /// A tournament player user, containing simple information about the player.
/// </summary> /// </summary>
[Serializable] [Serializable]
public class TournamentPlayer : IUser public class TournamentUser : IUser
{ {
[JsonProperty(@"id")] [JsonProperty(@"id")]
public int OnlineID { get; set; } public int OnlineID { get; set; }
@ -34,7 +34,7 @@ namespace osu.Game.Tournament.Models
/// </summary> /// </summary>
public string CoverUrl { get; set; } = string.Empty; public string CoverUrl { get; set; } = string.Empty;
public APIUser ToUser() public APIUser ToAPIUser()
{ {
var user = new APIUser var user = new APIUser
{ {

View File

@ -201,14 +201,14 @@ namespace osu.Game.Tournament.Screens.Editors
public void CreateNew() public void CreateNew()
{ {
var player = new TournamentPlayer(); var player = new TournamentUser();
team.Players.Add(player); team.Players.Add(player);
flow.Add(new PlayerRow(team, player)); flow.Add(new PlayerRow(team, player));
} }
public class PlayerRow : CompositeDrawable public class PlayerRow : CompositeDrawable
{ {
private readonly TournamentPlayer player; private readonly TournamentUser user;
[Resolved] [Resolved]
protected IAPIProvider API { get; private set; } protected IAPIProvider API { get; private set; }
@ -220,9 +220,9 @@ namespace osu.Game.Tournament.Screens.Editors
private readonly Container drawableContainer; private readonly Container drawableContainer;
public PlayerRow(TournamentTeam team, TournamentPlayer player) public PlayerRow(TournamentTeam team, TournamentUser user)
{ {
this.player = player; this.user = user;
Margin = new MarginPadding(10); Margin = new MarginPadding(10);
@ -271,7 +271,7 @@ namespace osu.Game.Tournament.Screens.Editors
Action = () => Action = () =>
{ {
Expire(); Expire();
team.Players.Remove(player); team.Players.Remove(user);
}, },
} }
}; };
@ -280,27 +280,27 @@ namespace osu.Game.Tournament.Screens.Editors
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
playerId.Value = player.OnlineID; playerId.Value = user.OnlineID;
playerId.BindValueChanged(id => playerId.BindValueChanged(id =>
{ {
player.OnlineID = id.NewValue ?? 0; user.OnlineID = id.NewValue ?? 0;
if (id.NewValue != id.OldValue) if (id.NewValue != id.OldValue)
player.Username = string.Empty; user.Username = string.Empty;
if (!string.IsNullOrEmpty(player.Username)) if (!string.IsNullOrEmpty(user.Username))
{ {
updatePanel(); updatePanel();
return; return;
} }
game.PopulatePlayer(player, updatePanel, updatePanel); game.PopulatePlayer(user, updatePanel, updatePanel);
}, true); }, true);
} }
private void updatePanel() private void updatePanel()
{ {
drawableContainer.Child = new UserGridPanel(player.ToUser()) { Width = 300 }; drawableContainer.Child = new UserGridPanel(user.ToAPIUser()) { Width = 300 };
} }
} }
} }

View File

@ -256,9 +256,9 @@ namespace osu.Game.Tournament
private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s); private void updateLoadProgressMessage(string s) => Schedule(() => initialisationText.Text = s);
public void PopulatePlayer(TournamentPlayer player, Action success = null, Action failure = null, bool immediate = false) public void PopulatePlayer(TournamentUser user, Action success = null, Action failure = null, bool immediate = false)
{ {
var req = new GetUserRequest(player.OnlineID, ladder.Ruleset.Value); var req = new GetUserRequest(user.OnlineID, ladder.Ruleset.Value);
if (immediate) if (immediate)
{ {
@ -270,7 +270,7 @@ namespace osu.Game.Tournament
req.Success += res => { populate(); }; req.Success += res => { populate(); };
req.Failure += _ => req.Failure += _ =>
{ {
player.OnlineID = 1; user.OnlineID = 1;
failure?.Invoke(); failure?.Invoke();
}; };
@ -284,12 +284,12 @@ namespace osu.Game.Tournament
if (res == null) if (res == null)
return; return;
player.OnlineID = res.Id; user.OnlineID = res.Id;
player.Username = res.Username; user.Username = res.Username;
player.CoverUrl = res.CoverUrl; user.CoverUrl = res.CoverUrl;
player.Country = res.Country; user.Country = res.Country;
player.Rank = res.Statistics?.GlobalRank; user.Rank = res.Statistics?.GlobalRank;
success?.Invoke(); success?.Invoke();
} }