X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Fvariants%2FZen.js;h=bfc0e0abe915de45f248d273f56692e47642bdff;hb=818ede16c09c2f5650d7a6b7b5ea42d6dd1a0c30;hp=54c77ad2889288c17be3ed264bdfc0ed243f9df0;hpb=1d184b4c016a645228251ce984d4c980e60420b0;p=vchess.git diff --git a/public/javascripts/variants/Zen.js b/public/javascripts/variants/Zen.js index 54c77ad2..bfc0e0ab 100644 --- a/public/javascripts/variants/Zen.js +++ b/public/javascripts/variants/Zen.js @@ -1,5 +1,11 @@ class ZenRules extends ChessRules { + // NOTE: enPassant, if enabled, would need to redefine carefully getEpSquare + getEpSquare(move) + { + return undefined; + } + // TODO: some duplicated code in 2 next functions getSlideNJumpMoves(x, y, color, steps, oneStep) { @@ -108,6 +114,7 @@ class ZenRules extends ChessRules let [sizeX,sizeY] = VariantRules.size; let shift = (color == 'w' ? -1 : 1); let startRank = (color == 'w' ? sizeY-2 : 1); + let firstRank = (color == 'w' ? sizeY-1 : 0); let lastRank = (color == "w" ? 0 : sizeY-1); if (x+shift >= 0 && x+shift < sizeX && x+shift != lastRank) @@ -116,7 +123,7 @@ class ZenRules extends ChessRules if (this.board[x+shift][y] == V.EMPTY) { moves.push(this.getBasicMove(x, y, x+shift, y)); - if (x==startRank && this.board[x+2*shift][y] == V.EMPTY) + 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)); @@ -135,21 +142,7 @@ class ZenRules extends ChessRules }); } - // En passant - const Lep = this.epSquares.length; - const epSquare = Lep>0 ? this.epSquares[Lep-1] : undefined; - if (!!epSquare && epSquare.x == x+shift && Math.abs(epSquare.y - y) == 1) - { - let epStep = epSquare.y - y; - var enpassantMove = this.getBasicMove(x, y, x+shift, y+epStep); - enpassantMove.vanish.push({ - x: x, - y: y+epStep, - p: 'p', - c: this.getColor(x,y+epStep) - }); - moves.push(enpassantMove); - } + // No en passant here // Add "zen" captures Array.prototype.push.apply(moves, this.findCaptures(x, y, color)); @@ -224,7 +217,7 @@ class ZenRules extends ChessRules String.fromCharCode(97 + move.end.y) + (VariantRules.size[0]-move.end.x); let notation = ""; - let piece = this.rules.getPiece(move.start.x, move.start.y); + let piece = this.getPiece(move.start.x, move.start.y); if (piece == VariantRules.PAWN) { // pawn move (TODO: enPassant indication)