X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FZen.js;h=56e7108b8cc3e73a7a369cd087df470e85de220c;hb=32f6285ee325a14286562a53baefc647201df2af;hp=a6067f9c697c4e4c1de5eddad523a3206f3d6922;hpb=9bd6786b863c31c3ccd0057b87cf454c90886056;p=vchess.git diff --git a/client/src/variants/Zen.js b/client/src/variants/Zen.js index a6067f9c..56e7108b 100644 --- a/client/src/variants/Zen.js +++ b/client/src/variants/Zen.js @@ -1,6 +1,6 @@ import { ChessRules } from "@/base_rules"; -export const VariantRules = class ZenRules extends ChessRules { +export class ZenRules extends ChessRules { // NOTE: enPassant, if enabled, would need to redefine carefully getEpSquare static get HasEnpassant() { return false; @@ -88,45 +88,14 @@ export const VariantRules = class ZenRules extends ChessRules { return moves; } - getPotentialPawnMoves([x, y]) { - const color = this.getColor(x, y); - let moves = []; - const sizeY = V.size.y; - const shift = color == "w" ? -1 : 1; - const startRank = color == "w" ? sizeY - 2 : 1; - const firstRank = color == "w" ? sizeY - 1 : 0; - const lastRank = color == "w" ? 0 : sizeY - 1; - - if (x + shift != lastRank) { - // Normal moves - if (this.board[x + shift][y] == V.EMPTY) { - moves.push(this.getBasicMove([x, y], [x + shift, y])); - if ( - [startRank, firstRank].includes(x) && - this.board[x + 2 * shift][y] == V.EMPTY - ) { - // Two squares jump - moves.push(this.getBasicMove([x, y], [x + 2 * shift, y])); - } - } - } - else { - // Promotion - let promotionPieces = [V.ROOK, V.KNIGHT, V.BISHOP, V.QUEEN]; - promotionPieces.forEach(p => { - // Normal move - if (this.board[x + shift][y] == V.EMPTY) - moves.push( - this.getBasicMove([x, y], [x + shift, y], { c: color, p: p }) - ); - }); - } - - // No en passant here + canTake(sq1, sq2) { + return false; //captures handled separately + } + getPotentialPawnMoves([x, y]) { + let moves = super.getPotentialPawnMoves([x, y]); // Add "zen" captures Array.prototype.push.apply(moves, this.findCaptures([x, y])); - return moves; }