|
|
|
@ -160,7 +160,7 @@ namespace QwirkleClassLibrary.Games
|
|
|
|
|
/// <returns>Board</returns>
|
|
|
|
|
public Board CreateBoard()
|
|
|
|
|
{
|
|
|
|
|
Board = new Board(15, 12);
|
|
|
|
|
Board = new Board(7, 7);
|
|
|
|
|
return Board;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -627,7 +627,7 @@ namespace QwirkleClassLibrary.Games
|
|
|
|
|
int dx = adjacentCell.GetX - cell.GetX;
|
|
|
|
|
int dy = adjacentCell.GetY - cell.GetY;
|
|
|
|
|
|
|
|
|
|
score += CalculateLineScore(cell, dx, dy, b, cellsX, cellsY, ref nbCellsInLine);
|
|
|
|
|
score += CalculateLineScore(cellsPlayed, cell, dx, dy, b, cellsX, cellsY, ref nbCellsInLine);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return score;
|
|
|
|
@ -636,6 +636,7 @@ namespace QwirkleClassLibrary.Games
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Extension of GetPlayerScore to calculate the score of the player based on the line/column of the adjacent cells
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="cellsPlayed"></param>
|
|
|
|
|
/// <param name="cell"></param>
|
|
|
|
|
/// <param name="dx"></param>
|
|
|
|
|
/// <param name="dy"></param>
|
|
|
|
@ -644,7 +645,7 @@ namespace QwirkleClassLibrary.Games
|
|
|
|
|
/// <param name="cellsY"></param>
|
|
|
|
|
/// <param name="nbCellsInLine"></param>
|
|
|
|
|
/// <returns>int</returns>
|
|
|
|
|
public int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY, ref int nbCellsInLine)
|
|
|
|
|
public int CalculateLineScore(ReadOnlyCollection<Cell> cellsPlayed, Cell cell, int dx, int dy, Board b, int cellsX, int cellsY, ref int nbCellsInLine)
|
|
|
|
|
{
|
|
|
|
|
int score = 0;
|
|
|
|
|
|
|
|
|
@ -652,9 +653,9 @@ namespace QwirkleClassLibrary.Games
|
|
|
|
|
{
|
|
|
|
|
var extendedCell = b.GetCell(cell.GetX + i * dx, cell.GetY + i * dy);
|
|
|
|
|
|
|
|
|
|
if (extendedCell?.GetTile == null)
|
|
|
|
|
if (extendedCell?.GetTile == null || cellsPlayed.Contains(extendedCell))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dx != 0 && cellsX == -1 || dy != 0 && cellsY == -1)
|
|
|
|
@ -704,23 +705,23 @@ namespace QwirkleClassLibrary.Games
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool CheckPlacementPossibilities(List<int> playerTilesBagPos)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < playerTilesBagPos.Count; i++)
|
|
|
|
|
foreach (var t1 in playerTilesBagPos)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < players[playerTilesBagPos[i]].Tiles.Count; j++)
|
|
|
|
|
foreach (var t in players[t1].Tiles)
|
|
|
|
|
{
|
|
|
|
|
for (int b = 0; b < Board!.ReadCells.Count; b++)
|
|
|
|
|
{
|
|
|
|
|
int x = Board.ReadCells[b].GetX;
|
|
|
|
|
int y = Board.ReadCells[b].GetY;
|
|
|
|
|
|
|
|
|
|
if (IsMoveCorrect(players[playerTilesBagPos[i]].Tiles[j], x, y, Board))
|
|
|
|
|
if (IsMoveCorrect(t, x, y, Board))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|