|
|
@ -256,7 +256,7 @@ namespace QwirkleClassLibrary
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool CheckExtendedSurroundingCells(Tile tile, int x, int y, int dx, int dy, Board b)
|
|
|
|
/* public bool CheckExtendedSurroundingCells(Tile tile, int x, int y, int dx, int dy, Board b)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int i = 1; i < 7; i++)
|
|
|
|
for (int i = 1; i < 7; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -287,6 +287,31 @@ namespace QwirkleClassLibrary
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool CheckExtendedSurroundingCells(Tile tile, int x, int y, int dx, int dy, Board b)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int i = 1; i < 7; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var extendedCell = b.GetCell(x + i * dx, y + i * dy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (extendedCell?.GetTile == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (extendedCell.GetTile.GetColor != tile.GetColor && extendedCell.GetTile.GetShape != tile.GetShape)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (i == 6)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool CheckTilesInLine(List<Cell> cells, Board b, int x, int y)
|
|
|
|
public bool CheckTilesInLine(List<Cell> cells, Board b, int x, int y)
|
|
|
@ -313,17 +338,12 @@ namespace QwirkleClassLibrary
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsMoveCorrect(Tile t, int x, int y, Board b)
|
|
|
|
/*public bool IsMoveCorrect(Tile t, int x, int y, Board b)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!b.HasOccupiedCase())
|
|
|
|
if (!b.HasOccupiedCase())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (this.PlaceTile(this.GetPlayingPlayer(), t, x, y))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.AddCellUsed(this.GetBoard().GetCell(x, y));
|
|
|
|
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(t, "Tile correctly placed"));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var surroundingCells = new List<Cell?>
|
|
|
|
var surroundingCells = new List<Cell?>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -364,6 +384,45 @@ namespace QwirkleClassLibrary
|
|
|
|
}
|
|
|
|
}
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(t, "La tuile n'a pu etre placé"));
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(t, "La tuile n'a pu etre placé"));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsMoveCorrect(Tile t, int x, int y, Board b)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!b.HasOccupiedCase())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var surroundingCells = new List<Cell?>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
b.GetCell(x + 1, y),
|
|
|
|
|
|
|
|
b.GetCell(x - 1, y),
|
|
|
|
|
|
|
|
b.GetCell(x, y + 1),
|
|
|
|
|
|
|
|
b.GetCell(x, y - 1)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var cell in surroundingCells)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (cell?.GetTile == null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cell.GetTile.GetColor != t.GetColor && cell.GetTile.GetShape != t.GetShape)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dx = cell.GetX - x;
|
|
|
|
|
|
|
|
var dy = cell.GetY - y;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CheckExtendedSurroundingCells(t, x, y, dx, dy, b) == false)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return CheckTilesInLine(this.cellUsed, b, x, y) && surroundingCells.Any(cell => cell?.GetTile != null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int GetPlayerScore(Player player, ReadOnlyCollection<Cell> cellsPlayed, Board b)
|
|
|
|
public int GetPlayerScore(Player player, ReadOnlyCollection<Cell> cellsPlayed, Board b)
|
|
|
|