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