I've done it ! For fuck sake I've done it !
continuous-integration/drone/push Build is passing Details

test_old_branch
Jules LASCRET 11 months ago
parent b32d8b5e8e
commit 98b840235e

@ -401,8 +401,13 @@ namespace QwirkleClassLibrary.Games
public int GetPlayerScore(Player player, ReadOnlyCollection<Cell> cellsPlayed, Board b)
public int GetPlayerScore(Player player, ReadOnlyCollection<Cell> cellsPlayed, Board b)
{
if (cellsPlayed.Count == 0)
{
return 0;
}
int score = cellsPlayed.Count;
int cellsX = cellsPlayed[0].GetX;
@ -414,11 +419,15 @@ public int GetPlayerScore(Player player, ReadOnlyCollection<Cell> cellsPlayed, B
{
cellsX = -1;
}
else if (cellsY != cell.GetY && cellsY != -1)
{
cellsY = -1;
}
}
foreach (var cell in cellsPlayed)
{
score += CalculateAdjacentScore(cell, b, cellsPlayed, cellsX, cellsY);
}
@ -434,7 +443,7 @@ public int GetPlayerScore(Player player, ReadOnlyCollection<Cell> cellsPlayed, B
public int CalculateAdjacentScore(Cell cell, Board b, ReadOnlyCollection<Cell> cellsPlayed, int cellsX, int cellsY)
{
int score = 0;
var surroundingCells = new[]
{
b.GetCell(cell.GetX + 1, cell.GetY),
@ -442,20 +451,20 @@ public int GetPlayerScore(Player player, ReadOnlyCollection<Cell> cellsPlayed, B
b.GetCell(cell.GetX, cell.GetY + 1),
b.GetCell(cell.GetX, cell.GetY - 1)
};
foreach (var adjacentCell in surroundingCells)
{
if (adjacentCell?.GetTile == null || cellsPlayed.Contains(adjacentCell))
{
continue;
}
int dx = adjacentCell.GetX - cell.GetX;
int dy = adjacentCell.GetY - cell.GetY;
score += CalculateLineScore(cell, dx, dy, b, cellsX, cellsY);
}
return score;
}

Loading…
Cancel
Save