From: Benjamin Auder Date: Thu, 15 Apr 2021 12:29:53 +0000 (+0200) Subject: Fix RR notation + en-passant X-Git-Url: https://git.auder.net/game/%7B%7B%20asset%28%27mixstore/css/user/board.css%27%29%20%7D%7D?a=commitdiff_plain;h=f25f375ad0ee4797277510aab55fdb632adfde50;p=vchess.git Fix RR notation + en-passant --- diff --git a/client/src/variants/Cwda.js b/client/src/variants/Cwda.js index c5ecf092..40127208 100644 --- a/client/src/variants/Cwda.js +++ b/client/src/variants/Cwda.js @@ -192,6 +192,30 @@ export class CwdaRules extends ChessRules { ); } + getEpSquare(moveOrSquare) { + if (!moveOrSquare) return undefined; //TODO: necessary line?! + if (typeof moveOrSquare === "string") { + const square = moveOrSquare; + if (square == "-") return undefined; + return V.SquareToCoords(square); + } + // Argument is a move: + const move = moveOrSquare; + const s = move.start, + e = move.end; + if ( + s.y == e.y && + Math.abs(s.x - e.x) == 2 && + ['p', 'u', 'v'].includes(move.appear[0].p) + ) { + return { + x: (s.x + e.x) / 2, + y: s.y + }; + } + return undefined; //default + } + getPotentialMovesFrom(sq) { switch (this.getPiece(sq[0], sq[1])) { case V.C_ROOK: return this.getPotentialC_rookMoves(sq); @@ -572,4 +596,11 @@ export class CwdaRules extends ChessRules { return 2; } + getNotation(move) { + let notation = super.getNotation(move); + if (['u', 'v'].includes(move.appear[0].p)) + notation = notation.slice(0, -2); + return notation; + } + };