From d6604c35cf73381d89dbc097d418b967e3256395 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 26 Feb 2025 20:10:13 +0100 Subject: [PATCH] h --- javascript/game-logic.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/javascript/game-logic.js b/javascript/game-logic.js index e2217b5..354a374 100644 --- a/javascript/game-logic.js +++ b/javascript/game-logic.js @@ -135,4 +135,21 @@ function getCasualties(oldX, oldY, newX, newY) { return casualties; } +function canContinue(pieceRecord){ + const x = pieceRecord.x; + const y = pieceRecord.y; + const player = pieceRecord.player; + const type = pieceRecord.type; + + if((type == "queen" || player == "white") && (getCasualties(x+1, y+1, x+2, y+2).count() == 1 || getCasualties(x-1, y+1, x-2, y+2).count() == 1)){ + return true; + } + + if((type == "queen" || player == "black") && (getCasualties(x+1, y-1, x+2, y-2).count() == 1 || getCasualties(x-1, y-1, x-2, y-2).count() == 1)){ + return true; + } + + return false; +} + generateDefaultPositions(); \ No newline at end of file