From fd7295e824c0199ad5a1ea40ec4b1f0630a5d806 Mon Sep 17 00:00:00 2001 From: Benjamin Auder Date: Sat, 11 Apr 2020 21:36:04 +0200 Subject: [PATCH] Remove castling as an option to escape from check in Allmate variants --- client/src/variants/Allmate1.js | 7 ++++++- client/src/variants/Allmate2.js | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/client/src/variants/Allmate1.js b/client/src/variants/Allmate1.js index d07474b3..d07cf847 100644 --- a/client/src/variants/Allmate1.js +++ b/client/src/variants/Allmate1.js @@ -60,7 +60,12 @@ export class Allmate1Rules extends ChessRules { oppMoves = this.getPotentialQueenMoves([i, j]); break; case V.KING: - oppMoves = this.getPotentialKingMoves([i, j]); + // Do not allow castling to escape from check + oppMoves = super.getSlideNJumpMoves( + sq, + V.steps[V.ROOK].concat(V.steps[V.BISHOP]), + "oneStep" + ); break; } for (let om of oppMoves) { diff --git a/client/src/variants/Allmate2.js b/client/src/variants/Allmate2.js index 31d41bef..9ba91ef0 100644 --- a/client/src/variants/Allmate2.js +++ b/client/src/variants/Allmate2.js @@ -61,7 +61,12 @@ export class Allmate2Rules extends ChessRules { oppMoves = this.getPotentialQueenMoves([i, j]); break; case V.KING: - oppMoves = this.getPotentialKingMoves([i, j]); + // Do not allow castling to escape from check + oppMoves = super.getSlideNJumpMoves( + sq, + V.steps[V.ROOK].concat(V.steps[V.BISHOP]), + "oneStep" + ); break; } for (let om of oppMoves) { -- 2.44.0