From 231bba397e6ed8aa2c06ba0568f47419b5d16a10 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Mon, 4 Jan 2021 18:43:18 +0100 Subject: [PATCH] [Paco-Sako] At least forbid to castle when under direct check --- client/src/variants/Pacosako.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/client/src/variants/Pacosako.js b/client/src/variants/Pacosako.js index 2048d2c0..b88f2e3b 100644 --- a/client/src/variants/Pacosako.js +++ b/client/src/variants/Pacosako.js @@ -405,6 +405,23 @@ export class PacosakoRules extends ChessRules { return moves; } + getPotentialKingMoves(sq) { + let moves = this.getSlideNJumpMoves( + sq, + V.steps[V.ROOK].concat(V.steps[V.BISHOP]), + "oneStep" + ); + const c = this.turn; + const oppCol = V.GetOppCol(c); + if ( + !this.isAttacked(this.kingPos[c], oppCol) && + this.castleFlags[c].some(v => v < V.size.y) + ) { + moves = moves.concat(super.getCastleMoves(sq, null, true)); + } + return moves; + } + getEpSquare(moveOrSquare) { if (typeof moveOrSquare === "string") { const square = moveOrSquare; -- 2.44.0