From 5f2beb825c0f313645ff669fb04b50f195b50c2d Mon Sep 17 00:00:00 2001 From: "jules.lascret" Date: Sat, 18 May 2024 19:50:39 +0200 Subject: [PATCH] Added a new score possibility, not working properly yet ! --- Qwirkle/QwirkleClassLibrary/Games/Game.cs | 16 +++++++++++++--- Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Qwirkle/QwirkleClassLibrary/Games/Game.cs b/Qwirkle/QwirkleClassLibrary/Games/Game.cs index f8bb8d2..bdbff33 100644 --- a/Qwirkle/QwirkleClassLibrary/Games/Game.cs +++ b/Qwirkle/QwirkleClassLibrary/Games/Game.cs @@ -410,6 +410,11 @@ namespace QwirkleClassLibrary.Games int score = cellsPlayed.Count; + if (cellsPlayed.Count == 6) + { + score += 6; + } + int cellsX = cellsPlayed[0].GetX; int cellsY = cellsPlayed[0].GetY; @@ -462,17 +467,17 @@ namespace QwirkleClassLibrary.Games int dx = adjacentCell.GetX - cell.GetX; int dy = adjacentCell.GetY - cell.GetY; - score += CalculateLineScore(cell, dx, dy, b, cellsX, cellsY); + score += CalculateLineScore(cell, dx, dy, b, cellsX, cellsY, cellsPlayed.Count); } return score; } - public int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY) + public int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY, int nbCellsPlayed) { int score = 0; - for (int i = 1; i < 7; i++) + for (int i = 1; i < 6; i++) { var extendedCell = b.GetCell(cell.GetX + i * dx, cell.GetY + i * dy); @@ -481,6 +486,11 @@ namespace QwirkleClassLibrary.Games continue; } + if (dx != 0 && cellsY != -1 && nbCellsPlayed + i == 6 || dy != 0 && cellsX != -1 && nbCellsPlayed + i == 6) + { + score += 6; + } + score++; } diff --git a/Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs b/Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs index c2fe694..a10ad57 100644 --- a/Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs +++ b/Qwirkle/QwirkleClassLibrary/Games/IPlayer.cs @@ -23,5 +23,5 @@ public interface IPlayer int CalculateAdjacentScore(Cell cell, Board b, ReadOnlyCollection cellsPlayed, int cellsX, int cellsY); - int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY); + int CalculateLineScore(Cell cell, int dx, int dy, Board b, int cellsX, int cellsY, int nbCellsPlayed); } \ No newline at end of file