checkpoint
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
public class SessionMetadata
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Player1 { get; }
|
||||
public string? Player2 { get; private set; }
|
||||
public User Player1 { get; }
|
||||
public User? Player2 { get; private set; }
|
||||
public bool IsPrivate { get; }
|
||||
|
||||
public SessionMetadata(string name, bool isPrivate, string player1, string? player2 = null)
|
||||
public SessionMetadata(string name, bool isPrivate, User player1, User? player2 = null)
|
||||
{
|
||||
Name = name;
|
||||
IsPrivate = isPrivate;
|
||||
@@ -25,11 +25,27 @@
|
||||
Player2 = sessionModel.Player2;
|
||||
}
|
||||
|
||||
public void SetPlayer2(string playerName)
|
||||
public void SetPlayer2(User user)
|
||||
{
|
||||
Player2 = playerName;
|
||||
Player2 = user;
|
||||
}
|
||||
|
||||
public ServiceModels.Types.Game ToServiceModel() => new(Name, Player1, Player2);
|
||||
public bool IsSeated(User user) => user.Id == Player1.Id || user.Id == Player2?.Id;
|
||||
|
||||
public ServiceModels.Types.Game ToServiceModel(User? user = null)
|
||||
{
|
||||
// TODO: Find a better way for the UI to know whether or not they are seated at a given game than client-side ID matching.
|
||||
var player1 = Player1.DisplayName;
|
||||
var player2 = Player2?.DisplayName;
|
||||
if (user != null)
|
||||
{
|
||||
if (user.Id == Player1.Id) player1 = Player1.Id;
|
||||
if (Player2 != null && user.Id == Player2.Id)
|
||||
{
|
||||
player2 = Player2.DisplayName;
|
||||
}
|
||||
}
|
||||
return new(Name, player1, player2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user