X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FEightpieces.js;h=3e1550093bf809264a67d15d2afc71a011fe1167;hb=7e8a7ea1cb66adb4a987badfb0a3c2f99a21bd0a;hp=38f0d303fc1e5fa050c92c42659769cd752091f6;hpb=33974019f1ee5cc9a3f32f9beb8a0d6fe96af769;p=vchess.git diff --git a/client/src/variants/Eightpieces.js b/client/src/variants/Eightpieces.js index 38f0d303..3e155009 100644 --- a/client/src/variants/Eightpieces.js +++ b/client/src/variants/Eightpieces.js @@ -3,6 +3,7 @@ import { randInt } from "@/utils/alea"; import { ChessRules, PiPo, Move } from "@/base_rules"; export class EightpiecesRules extends ChessRules { + static get JAILER() { return "j"; } @@ -406,12 +407,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) { @@ -1188,4 +1195,5 @@ export class EightpiecesRules extends ChessRules { } return notation; } + };