1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 05:22:54 +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" },
Players =
{
new TournamentPlayer { Username = "ASecretBox" },
new TournamentPlayer { Username = "Dereban" },
new TournamentPlayer { Username = "mReKk" },
new TournamentPlayer { Username = "uyghti" },
new TournamentPlayer { Username = "Parkes" },
new TournamentPlayer { Username = "Shiroha" },
new TournamentPlayer { Username = "Jordan The Bear" },
new TournamentUser { Username = "ASecretBox" },
new TournamentUser { Username = "Dereban" },
new TournamentUser { Username = "mReKk" },
new TournamentUser { Username = "uyghti" },
new TournamentUser { Username = "Parkes" },
new TournamentUser { Username = "Shiroha" },
new TournamentUser { Username = "Jordan The Bear" },
}
};

View File

@ -27,13 +27,13 @@ namespace osu.Game.Tournament.Tests.Components
Colour = "f2ca34"
};
private readonly TournamentPlayer redPlayer = new TournamentPlayer
private readonly TournamentUser redUser = new TournamentUser
{
Username = "BanchoBot",
OnlineID = 3,
};
private readonly TournamentPlayer bluePlayer = new TournamentPlayer
private readonly TournamentUser blueUser = new TournamentUser
{
Username = "Zallius",
OnlineID = 4,
@ -59,11 +59,11 @@ namespace osu.Game.Tournament.Tests.Components
{
Team1 =
{
Value = new TournamentTeam { Players = new BindableList<TournamentPlayer> { redPlayer } }
Value = new TournamentTeam { Players = new BindableList<TournamentUser> { redUser } }
},
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())
{
Sender = redPlayer.ToUser(),
Sender = redUser.ToAPIUser(),
Content = "I am team red."
}));
AddStep("message from team red", () => testChannel.AddNewMessages(new Message(nextMessageId())
{
Sender = redPlayer.ToUser(),
Sender = redUser.ToAPIUser(),
Content = "I plan to win!"
}));
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."
}));

View File

@ -121,11 +121,11 @@ namespace osu.Game.Tournament.Tests
},
Players =
{
new TournamentPlayer { Username = "Hello", Rank = 12 },
new TournamentPlayer { Username = "Hello", Rank = 16 },
new TournamentPlayer { Username = "Hello", Rank = 20 },
new TournamentPlayer { Username = "Hello", Rank = 24 },
new TournamentPlayer { Username = "Hello", Rank = 30 },
new TournamentUser { Username = "Hello", Rank = 12 },
new TournamentUser { Username = "Hello", Rank = 16 },
new TournamentUser { Username = "Hello", Rank = 20 },
new TournamentUser { Username = "Hello", Rank = 24 },
new TournamentUser { Username = "Hello", Rank = 30 },
}
}
},
@ -138,11 +138,11 @@ namespace osu.Game.Tournament.Tests
FullName = { Value = "United States" },
Players =
{
new TournamentPlayer { Username = "Hello" },
new TournamentPlayer { Username = "Hello" },
new TournamentPlayer { Username = "Hello" },
new TournamentPlayer { Username = "Hello" },
new TournamentPlayer { Username = "Hello" },
new TournamentUser { Username = "Hello" },
new TournamentUser { Username = "Hello" },
new TournamentUser { Username = "Hello" },
new TournamentUser { 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
{
Text = p.Username,

View File

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

View File

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

View File

@ -201,14 +201,14 @@ namespace osu.Game.Tournament.Screens.Editors
public void CreateNew()
{
var player = new TournamentPlayer();
var player = new TournamentUser();
team.Players.Add(player);
flow.Add(new PlayerRow(team, player));
}
public class PlayerRow : CompositeDrawable
{
private readonly TournamentPlayer player;
private readonly TournamentUser user;
[Resolved]
protected IAPIProvider API { get; private set; }
@ -220,9 +220,9 @@ namespace osu.Game.Tournament.Screens.Editors
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);
@ -271,7 +271,7 @@ namespace osu.Game.Tournament.Screens.Editors
Action = () =>
{
Expire();
team.Players.Remove(player);
team.Players.Remove(user);
},
}
};
@ -280,27 +280,27 @@ namespace osu.Game.Tournament.Screens.Editors
[BackgroundDependencyLoader]
private void load()
{
playerId.Value = player.OnlineID;
playerId.Value = user.OnlineID;
playerId.BindValueChanged(id =>
{
player.OnlineID = id.NewValue ?? 0;
user.OnlineID = id.NewValue ?? 0;
if (id.NewValue != id.OldValue)
player.Username = string.Empty;
user.Username = string.Empty;
if (!string.IsNullOrEmpty(player.Username))
if (!string.IsNullOrEmpty(user.Username))
{
updatePanel();
return;
}
game.PopulatePlayer(player, updatePanel, updatePanel);
game.PopulatePlayer(user, updatePanel, updatePanel);
}, true);
}
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);
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)
{
@ -270,7 +270,7 @@ namespace osu.Game.Tournament
req.Success += res => { populate(); };
req.Failure += _ =>
{
player.OnlineID = 1;
user.OnlineID = 1;
failure?.Invoke();
};
@ -284,12 +284,12 @@ namespace osu.Game.Tournament
if (res == null)
return;
player.OnlineID = res.Id;
user.OnlineID = res.Id;
player.Username = res.Username;
player.CoverUrl = res.CoverUrl;
player.Country = res.Country;
player.Rank = res.Statistics?.GlobalRank;
user.Username = res.Username;
user.CoverUrl = res.CoverUrl;
user.Country = res.Country;
user.Rank = res.Statistics?.GlobalRank;
success?.Invoke();
}