using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; using QwirkleClassLibrary.Tiles; namespace QwirkleClassLibrary.Boards { public class Board { public ReadOnlyCollection ReadCells => cells.AsReadOnly(); private readonly List cells = new(); public int Rows { get; } public int Columns { get; } public Board(int rows, int cols) { Rows = rows; Columns = cols; for (int a = 0; a < Rows; a++) { for (int b = 0; b < Columns; b++) { Cell localcell = new(a, b); cells.Add(localcell); } } } public bool HasOccupiedCase() { foreach (var cell in cells) { if (!cell.IsFree) { return true; } } return false; } public bool AddTileInCell(int x, int y, Tile tile) { foreach (var t in cells) { if (t.GetX != x || t.GetY != y) continue; if (t.IsFree) { return t.SetTile(tile); } } return false; } public List GetCells() { return cells; } public IReadOnlyCollection GetReadCells() { return ReadCells; } public Cell? GetCell(int x, int y) { foreach (var t in cells) { if (t.GetX == x && t.GetY == y) { return t; } } return null; } } }