slight changes on Board.cs, Tile.cs and TileBag.cs

test_old_branch
Jules LASCRET 12 months ago
parent 632617f509
commit d1e184f7ca

@ -9,33 +9,32 @@ namespace QwirkleClassLibrary
{ {
public class Board public class Board
{ {
private List<Cell> Cells; private List<Cell> cells;
public IReadOnlyCollection<Cell> ReadCells { get; private set; } public IReadOnlyCollection<Cell> ReadCells { get; private set; }
// ReadCells = Cells.AsReadOnly;
public Board() public Board()
{ {
Cells = new List<Cell>(); cells = new List<Cell>();
for (int i = 0; i < 12; i++) for (int i = 0; i < 12; i++)
{ {
for (int j = 0; j < 12; j++) for (int j = 0; j < 12; j++)
{ {
Cell localcell = new(i, j); Cell localcell = new(i, j);
Cells.Add(localcell); cells.Add(localcell);
} }
} }
} }
public bool AddTileInCell(int x, int y, Tile tile) public bool AddTileInCell(int x, int y, Tile tile)
{ {
for (int i = 0; i < Cells.Count; i++) for (int i = 0; i < cells.Count; i++)
{ {
if (this.Cells[i].GetX == x && this.Cells[i].GetY == y) if (this.cells[i].GetX == x && this.cells[i].GetY == y)
{ {
if (Cells[i].IsFree == true) if (cells[i].IsFree == true)
{ {
return Cells[i].SetTile(tile); return cells[i].SetTile(tile);
} }
} }

@ -23,6 +23,7 @@ namespace QwirkleClassLibrary
{ {
return color.ToString() + shape.ToString(); return color.ToString() + shape.ToString();
} }
public Shape GetShape public Shape GetShape
{ {
get { return this.shape; } get { return this.shape; }
@ -35,7 +36,7 @@ namespace QwirkleClassLibrary
public override string ToString() public override string ToString()
{ {
return shape.ToString() + color.ToString(); return color.ToString() + shape.ToString();
} }
} }
} }

@ -28,6 +28,11 @@ namespace QwirkleClassLibrary
TilesBag = tiles.AsReadOnly(); TilesBag = tiles.AsReadOnly();
} }
public void AddTileInBag(Tile tile)
{
tiles.Add(tile);
}
public void RemoveTileInBag(Tile tile) public void RemoveTileInBag(Tile tile)
{ {
for (int i = 0; i < tiles.Count; i++) for (int i = 0; i < tiles.Count; i++)
@ -39,6 +44,4 @@ namespace QwirkleClassLibrary
} }
} }
} }
} }

Loading…
Cancel
Save