From: Benjamin Auder Date: Sat, 11 Apr 2020 19:36:04 +0000 (+0200) Subject: Remove castling as an option to escape from check in Allmate variants X-Git-Url: https://git.auder.net/js/current/app_dev.php/rpsls.js?a=commitdiff_plain;h=fd7295e824c0199ad5a1ea40ec4b1f0630a5d806;p=vchess.git Remove castling as an option to escape from check in Allmate variants --- 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) {