From: Benjamin Auder Date: Thu, 16 Apr 2020 15:35:12 +0000 (+0200) Subject: Fix Alice rules (en passant) X-Git-Url: https://git.auder.net/variants/current/css/img/scripts/getGraph_%22%20%20%20this.image%20%20%20%22.php?a=commitdiff_plain;h=1be09254408b05e3c1dd43b34e4c06cebd50af72;p=vchess.git Fix Alice rules (en passant) --- diff --git a/client/src/base_rules.js b/client/src/base_rules.js index 53001f63..ec949fcc 100644 --- a/client/src/base_rules.js +++ b/client/src/base_rules.js @@ -807,7 +807,6 @@ export const ChessRules = class ChessRules { this.getEnpassantCaptures([x, y], pawnShiftX) ); } - return pMoves; } diff --git a/client/src/variants/Alice.js b/client/src/variants/Alice.js index 3fd02a32..57de5683 100644 --- a/client/src/variants/Alice.js +++ b/client/src/variants/Alice.js @@ -191,6 +191,31 @@ export class AliceRules extends ChessRules { return res; } + getEnpassantCaptures([x, y], shiftX) { + const Lep = this.epSquares.length; + const epSquare = this.epSquares[Lep - 1]; //always at least one element + let enpassantMove = null; + if ( + !!epSquare && + epSquare.x == x + shiftX && + Math.abs(epSquare.y - y) == 1 + ) { + enpassantMove = this.getBasicMove([x, y], [epSquare.x, epSquare.y]); + // May capture in same world or different: + const capturedPiece = + this.board[x][epSquare.y] != V.EMPTY + ? this.getPiece(x, epSquare.y) + : ['p','s'][1 - "ps".indexOf(this.getPiece(x, y))]; + enpassantMove.vanish.push({ + x: x, + y: epSquare.y, + p: capturedPiece, + c: V.GetOppCol(this.turn) + }); + } + return !!enpassantMove ? [enpassantMove] : []; + } + filterValid(moves, sideBoard) { if (moves.length == 0) return []; if (!sideBoard) sideBoard = [this.getSideBoard(1), this.getSideBoard(2)];