Remove castling as an option to escape from check in Allmate variants
[vchess.git] / client / src / variants / Allmate1.js
index 3d84300..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) {
@@ -203,8 +208,7 @@ export class Allmate1Rules extends ChessRules {
     if (kp[0] < 0)
       // King disappeared
       return color == "w" ? "0-1" : "1-0";
-    if (this.atLeastOneMove())
-      return "*";
+    if (this.atLeastOneMove()) return "*";
     // Kings still there, no moves:
     return "1/2";
   }