|
|
|
@ -23,7 +23,7 @@ namespace QwirkleClassLibrary
|
|
|
|
|
|
|
|
|
|
public Game()
|
|
|
|
|
{
|
|
|
|
|
bag = CreateTileBag(1);
|
|
|
|
|
bag = CreateTileBag(3);
|
|
|
|
|
board = CreateBoard();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -63,7 +63,7 @@ namespace QwirkleClassLibrary
|
|
|
|
|
|
|
|
|
|
public Board CreateBoard()
|
|
|
|
|
{
|
|
|
|
|
board = new Board(5, 5);
|
|
|
|
|
board = new Board(8, 8);
|
|
|
|
|
return board;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -214,28 +214,90 @@ namespace QwirkleClassLibrary
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var surroundingTiles = new List<Tile?>();
|
|
|
|
|
var surroundingCells = new List<Cell?>();
|
|
|
|
|
|
|
|
|
|
surroundingTiles.Add(b.GetCell(x + 1, y)?.GetTile);
|
|
|
|
|
surroundingTiles.Add(b.GetCell(x - 1, y)?.GetTile);
|
|
|
|
|
surroundingTiles.Add(b.GetCell(x, y + 1)?.GetTile);
|
|
|
|
|
surroundingTiles.Add(b.GetCell(x, y - 1)?.GetTile);
|
|
|
|
|
surroundingCells.Add(b.GetCell(x + 1, y));
|
|
|
|
|
surroundingCells.Add(b.GetCell(x - 1, y));
|
|
|
|
|
surroundingCells.Add(b.GetCell(x, y + 1));
|
|
|
|
|
surroundingCells.Add(b.GetCell(x, y - 1));
|
|
|
|
|
|
|
|
|
|
foreach (var tile in surroundingTiles.ToList())
|
|
|
|
|
foreach (var cell in surroundingCells.ToList())
|
|
|
|
|
{
|
|
|
|
|
if (tile == null)
|
|
|
|
|
if (cell?.GetTile == null)
|
|
|
|
|
{
|
|
|
|
|
surroundingTiles.Remove(tile);
|
|
|
|
|
surroundingCells.Remove(cell);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tile.GetColor != t.GetColor && tile.GetShape != t.GetShape)
|
|
|
|
|
if (cell?.GetTile.GetColor != t.GetColor && cell?.GetTile.GetShape != t.GetShape)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(surroundingTiles.Count == 0) return false;
|
|
|
|
|
if(surroundingCells.Count == 0) return false;
|
|
|
|
|
|
|
|
|
|
foreach (var cell in surroundingCells.ToList())
|
|
|
|
|
{
|
|
|
|
|
var extendedCells = new List<Cell?>();
|
|
|
|
|
|
|
|
|
|
if (cell?.GetX == x && cell?.GetY == y + 1)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
if (b.GetCell(x, y + i)?.GetTile != null)
|
|
|
|
|
{
|
|
|
|
|
extendedCells.Add(b.GetCell(x, y + i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (cell?.GetX == x && cell?.GetY == y - 1)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
if (b.GetCell(x, y - i)?.GetTile != null)
|
|
|
|
|
{
|
|
|
|
|
extendedCells.Add(b.GetCell(x, y - i));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (cell?.GetX == x + 1 && cell?.GetY == y)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
if (b.GetCell(x + i, y)?.GetTile != null)
|
|
|
|
|
{
|
|
|
|
|
extendedCells.Add(b.GetCell(x + i, y));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if (cell?.GetX == x - 1 && cell?.GetY == y)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i < 7; i++)
|
|
|
|
|
{
|
|
|
|
|
if (b.GetCell(x - i, y)?.GetTile != null)
|
|
|
|
|
{
|
|
|
|
|
extendedCells.Add(b.GetCell(x - i, y));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var e in extendedCells)
|
|
|
|
|
{
|
|
|
|
|
if (e?.GetTile?.GetColor != t.GetColor && e?.GetTile?.GetShape != t.GetShape)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (extendedCells.Count == 6)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|