|
|
|
@ -21,6 +21,11 @@ namespace QwirkleClassLibrary
|
|
|
|
|
public ReadOnlyCollection<Score> ScoreList => scores.AsReadOnly();
|
|
|
|
|
private readonly List<Score> scores = new();
|
|
|
|
|
|
|
|
|
|
public event EventHandler<AddPlayerNotifiedEventArgs> PlayerAddNotified;
|
|
|
|
|
|
|
|
|
|
protected virtual void OnPlayerNotified(AddPlayerNotifiedEventArgs args)
|
|
|
|
|
=> PlayerAddNotified?.Invoke(this, args);
|
|
|
|
|
|
|
|
|
|
public Game()
|
|
|
|
|
{
|
|
|
|
|
bag = new TileBag(3);
|
|
|
|
@ -31,11 +36,13 @@ namespace QwirkleClassLibrary
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(playerTag) == true || this.GameRunning == true)
|
|
|
|
|
{
|
|
|
|
|
OnPlayerNotified(new AddPlayerNotifiedEventArgs(1));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (players.Count >= 4)
|
|
|
|
|
{
|
|
|
|
|
OnPlayerNotified(new AddPlayerNotifiedEventArgs(2));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -43,19 +50,22 @@ namespace QwirkleClassLibrary
|
|
|
|
|
{
|
|
|
|
|
if (p.NameTag == playerTag)
|
|
|
|
|
{
|
|
|
|
|
OnPlayerNotified(new AddPlayerNotifiedEventArgs(3));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
players.Add(CreatePlayer(playerTag));
|
|
|
|
|
scores.Add(new Score(players[players.Count-1]));
|
|
|
|
|
|
|
|
|
|
OnPlayerNotified(new AddPlayerNotifiedEventArgs(0));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Player CreatePlayer(string playerTag)
|
|
|
|
|
{
|
|
|
|
|
var player = new Player(playerTag);
|
|
|
|
|
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|