X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FShatranj.js;h=d8e4460e85a19fd1b9fea1f5577003e4edef3000;hb=107dc1bd5361e2538b1551bdcc37c1e90a444b83;hp=969b8197606c8872b84b13e8953a9b0118baddb7;hpb=68e19a449db7a12e0a168e99cd750d985c983ba1;p=vchess.git diff --git a/client/src/variants/Shatranj.js b/client/src/variants/Shatranj.js index 969b8197..d8e4460e 100644 --- a/client/src/variants/Shatranj.js +++ b/client/src/variants/Shatranj.js @@ -1,6 +1,6 @@ import { ChessRules } from "@/base_rules"; -export const VariantRules = class ShatranjRules extends ChessRules { +export class ShatranjRules extends ChessRules { static get HasFlags() { return false; } @@ -9,6 +9,26 @@ export const VariantRules = class ShatranjRules extends ChessRules { return false; } + static get Monochrome() { + return true; + } + + static get PawnSpecs() { + return Object.assign( + {}, + ChessRules.PawnSpecs, + { + twoSquares: false, + promotions: [V.QUEEN] + } + ); + } + + getPpath(b) { + if (b[1] == 'b') return "Shatranj/" + b; + return b; + } + static get ElephantSteps() { return [ [-2, -2], @@ -23,45 +43,6 @@ export const VariantRules = class ShatranjRules extends ChessRules { return ChessRules.GenRandInitFen(randomness).slice(0, -7); } - getPotentialPawnMoves([x, y]) { - const color = this.turn; - let moves = []; - const [sizeX, sizeY] = [V.size.x, V.size.y]; - const shiftX = color == "w" ? -1 : 1; - const startRank = color == "w" ? sizeX - 2 : 1; - const lastRank = color == "w" ? 0 : sizeX - 1; - // Promotion in minister (queen) only: - const finalPiece = x + shiftX == lastRank ? V.QUEEN : V.PAWN; - - if (this.board[x + shiftX][y] == V.EMPTY) { - // One square forward - moves.push( - this.getBasicMove([x, y], [x + shiftX, y], { - c: color, - p: finalPiece - }) - ); - } - // Captures - for (let shiftY of [-1, 1]) { - if ( - y + shiftY >= 0 && - y + shiftY < sizeY && - this.board[x + shiftX][y + shiftY] != V.EMPTY && - this.canTake([x, y], [x + shiftX, y + shiftY]) - ) { - moves.push( - this.getBasicMove([x, y], [x + shiftX, y + shiftY], { - c: color, - p: finalPiece - }) - ); - } - } - - return moves; - } - getPotentialBishopMoves(sq) { let moves = this.getSlideNJumpMoves(sq, V.ElephantSteps, "oneStep"); // Complete with "repositioning moves": like a queen, without capture @@ -90,14 +71,6 @@ export const VariantRules = class ShatranjRules extends ChessRules { ); } - getPotentialKingMoves(sq) { - return this.getSlideNJumpMoves( - sq, - V.steps[V.ROOK].concat(V.steps[V.BISHOP]), - "oneStep" - ); - } - isAttackedByBishop(sq, color) { return this.isAttackedBySlideNJump( sq,