Remove castling as an option to escape from check in Allmate variants
authorBenjamin Auder <benjamin.auder@somewhere>
Sat, 11 Apr 2020 19:36:04 +0000 (21:36 +0200)
committerBenjamin Auder <benjamin.auder@somewhere>
Sat, 11 Apr 2020 19:36:04 +0000 (21:36 +0200)
client/src/variants/Allmate1.js
client/src/variants/Allmate2.js

index d07474b..d07cf84 100644 (file)
@@ -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) {
index 31d41be..9ba91ef 100644 (file)
@@ -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) {