From f25f375ad0ee4797277510aab55fdb632adfde50 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Thu, 15 Apr 2021 14:29:53 +0200 Subject: [PATCH] Fix RR notation + en-passant --- client/src/variants/Cwda.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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; + } + }; -- 2.44.0