X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FShatranj.js;h=00b145641d39524328f5b8b40106726d3ae65c24;hp=45a34c046b0f49d422e06a7f9a7d36eaa66114a1;hb=32f6285ee325a14286562a53baefc647201df2af;hpb=11482348f50058d235adb89bfc174a1da7c6abc4 diff --git a/client/src/variants/Shatranj.js b/client/src/variants/Shatranj.js index 45a34c04..00b14564 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; } @@ -13,6 +13,17 @@ export const VariantRules = class ShatranjRules extends ChessRules { return false; } + static get PawnSpecs() { + return Object.assign( + {}, + ChessRules.PawnSpecs, + { + twoSquares: false, + promotions: [V.QUEEN] + } + ); + } + static get ElephantSteps() { return [ [-2, -2], @@ -27,45 +38,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