X-Git-Url: https://git.auder.net/?p=vchess.git;a=blobdiff_plain;f=client%2Fsrc%2Fvariants%2FZen.js;h=0424e07f089f22c5cd8a0c00a4df8e64e4dd7c0c;hp=ff562d0adce48426a5d6e7769a5e4ca969ac5342;hb=ffeaef854d80445ef87f2cdf4fe71d60347a81bf;hpb=53814a101f5ca4e43939f9423d9c6469b158f55e diff --git a/client/src/variants/Zen.js b/client/src/variants/Zen.js index ff562d0a..0424e07f 100644 --- a/client/src/variants/Zen.js +++ b/client/src/variants/Zen.js @@ -1,9 +1,29 @@ import { ChessRules } from "@/base_rules"; export class ZenRules extends ChessRules { - // NOTE: enPassant, if enabled, would need to redefine carefully getEpSquare - static get HasEnpassant() { - return false; + getEpSquare(moveOrSquare) { + if (!moveOrSquare) return undefined; + if (typeof moveOrSquare === "string") { + const square = moveOrSquare; + if (square == "-") return undefined; + return V.SquareToCoords(square); + } + const move = moveOrSquare; + const s = move.start, + e = move.end; + if ( + // Exclude captures (of rooks for example) + move.vanish.length == 1 && + s.y == e.y && + Math.abs(s.x - e.x) == 2 && + move.appear[0].p == V.PAWN + ) { + return { + x: (s.x + e.x) / 2, + y: s.y + }; + } + return undefined; } // TODO(?): some duplicated code in 2 next functions