|
|
@ -1,18 +1,24 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
using System.Text;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using QwirkleClassLibrary.Tiles;
|
|
|
|
using QwirkleClassLibrary.Tiles;
|
|
|
|
|
|
|
|
|
|
|
|
namespace QwirkleClassLibrary.Players
|
|
|
|
namespace QwirkleClassLibrary.Players
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class Player
|
|
|
|
public class Player : INotifyPropertyChanged
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public ReadOnlyCollection<Tile> Tiles => playerTiles.AsReadOnly();
|
|
|
|
public ReadOnlyCollection<Tile> Tiles => playerTiles.AsReadOnly();
|
|
|
|
private readonly List<Tile> playerTiles = new();
|
|
|
|
private readonly List<Tile> playerTiles = new();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
|
|
|
|
void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
|
|
|
|
|
|
|
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Creates a player with a name
|
|
|
|
/// Creates a player with a name
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
@ -39,6 +45,7 @@ namespace QwirkleClassLibrary.Players
|
|
|
|
public void AddTileToPlayer(Tile tile)
|
|
|
|
public void AddTileToPlayer(Tile tile)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
playerTiles.Add(tile);
|
|
|
|
playerTiles.Add(tile);
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
@ -48,7 +55,12 @@ namespace QwirkleClassLibrary.Players
|
|
|
|
/// <returns>bool</returns>
|
|
|
|
/// <returns>bool</returns>
|
|
|
|
public bool RemoveTileToPlayer(Tile tile)
|
|
|
|
public bool RemoveTileToPlayer(Tile tile)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return playerTiles.Remove(tile);
|
|
|
|
if (playerTiles.Remove(tile))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
OnPropertyChanged();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|