|
|
@ -35,6 +35,11 @@ namespace QwirkleClassLibrary
|
|
|
|
protected virtual void OnNextPlayer(NextPlayerNotifiedEventArgs args)
|
|
|
|
protected virtual void OnNextPlayer(NextPlayerNotifiedEventArgs args)
|
|
|
|
=> NextPlayerNotified?.Invoke(this, args);
|
|
|
|
=> NextPlayerNotified?.Invoke(this, args);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public event EventHandler<PlaceTileNotifiedEventArgs>? PlaceTileNotified;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected virtual void OnPlaceTile(PlaceTileNotifiedEventArgs args)
|
|
|
|
|
|
|
|
=> PlaceTileNotified?.Invoke(this, args);
|
|
|
|
|
|
|
|
|
|
|
|
public Game()
|
|
|
|
public Game()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bag = CreateTileBag(3);
|
|
|
|
bag = CreateTileBag(3);
|
|
|
@ -264,11 +269,13 @@ namespace QwirkleClassLibrary
|
|
|
|
|
|
|
|
|
|
|
|
if (extendedCell.GetTile.GetColor != tile.GetColor && extendedCell.GetTile.GetShape != tile.GetShape)
|
|
|
|
if (extendedCell.GetTile.GetColor != tile.GetColor && extendedCell.GetTile.GetShape != tile.GetShape)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(tile, "Les couleurs/formes adjacentes ne correspondes pas"));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (i == 6)
|
|
|
|
if (i == 6)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(tile, "La ligne ou colonne fait deja 6 tuiles !"));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -304,7 +311,12 @@ namespace QwirkleClassLibrary
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!b.HasOccupiedCase())
|
|
|
|
if (!b.HasOccupiedCase())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
if (this.PlaceTile(this.GetPlayingPlayer(), t, x, y) == true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.AddCellUsed(this.GetBoard().GetCell(x, y));
|
|
|
|
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(t, "Tile correctement placé"));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var surroundingCells = new List<Cell?>
|
|
|
|
var surroundingCells = new List<Cell?>
|
|
|
@ -324,6 +336,7 @@ namespace QwirkleClassLibrary
|
|
|
|
|
|
|
|
|
|
|
|
if (cell.GetTile.GetColor != t.GetColor && cell.GetTile.GetShape != t.GetShape)
|
|
|
|
if (cell.GetTile.GetColor != t.GetColor && cell.GetTile.GetShape != t.GetShape)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(t, "Tile ne correspond pas au bonne couleur des tiles a coté"));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -336,7 +349,18 @@ namespace QwirkleClassLibrary
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return CheckTilesInLine(this.cellUsed, b, x, y) && surroundingCells.Any(cell => cell?.GetTile != null);
|
|
|
|
if (CheckTilesInLine(this.cellUsed, b, x, y) && surroundingCells.Any(cell => cell?.GetTile != null))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(this.PlaceTile(this.GetPlayingPlayer(), t, x, y) == true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.AddCellUsed(this.GetBoard().GetCell(x, y));
|
|
|
|
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(t, "Tile correctement placé"));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(t, "Cell Already use"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OnPlaceTile(new PlaceTileNotifiedEventArgs(t, "La tuile n'a pu etre placé"));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int GetPlayerScore(Player player, List<Cell> cellsPlayed, Board board)
|
|
|
|
public int GetPlayerScore(Player player, List<Cell> cellsPlayed, Board board)
|
|
|
|