X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FEightpieces.js;h=583b1c5ac5a14e609324a274136da6d39cea31ec;hp=38f0d303fc1e5fa050c92c42659769cd752091f6;hb=7f1df0d95d2190fd69ef7c58f5a795aef3f92869;hpb=c494576a9af379d88500c2e7b23428397ea749b4 diff --git a/client/src/variants/Eightpieces.js b/client/src/variants/Eightpieces.js index 38f0d303..583b1c5a 100644 --- a/client/src/variants/Eightpieces.js +++ b/client/src/variants/Eightpieces.js @@ -406,12 +406,18 @@ export class EightpiecesRules extends ChessRules { // Pawns might be pushed on 1st rank and attempt to move again: if (!V.OnBoard(x + shiftX, y)) return []; - const finalPieces = - // A push cannot put a pawn on last rank (it goes backward) - x + shiftX == lastRank - ? Object.keys(V.LANCER_DIRS).concat( - [V.ROOK, V.KNIGHT, V.BISHOP, V.QUEEN, V.SENTRY, V.JAILER]) - : [V.PAWN]; + // A push cannot put a pawn on last rank (it goes backward) + let finalPieces = [V.PAWN]; + if (x + shiftX == lastRank) { + // Only allow direction facing inside board: + const allowedLancerDirs = + lastRank == 0 + ? ['e', 'f', 'g', 'h', 'm'] + : ['c', 'd', 'e', 'm', 'o']; + finalPieces = + allowedLancerDirs + .concat([V.ROOK, V.KNIGHT, V.BISHOP, V.QUEEN, V.SENTRY, V.JAILER]); + } if (this.board[x + shiftX][y] == V.EMPTY) { // One square forward for (let piece of finalPieces) {