Change castle flags. Eightpieces still not OK, but almost
[vchess.git] / client / src / variants / Arena.js
index b92be1e..620b980 100644 (file)
@@ -1,12 +1,12 @@
 import { ChessRules } from "@/base_rules";
 
 export const VariantRules = class ArenaRules extends ChessRules {
-  static get hasFlags() {
+  static get HasFlags() {
     return false;
   }
 
-  static GenRandInitFen() {
-    return ChessRules.GenRandInitFen().replace("w 1111 -", "w -");
+  static GenRandInitFen(randomness) {
+    return ChessRules.GenRandInitFen(randomness).slice(0, -6) + "-";
   }
 
   static InArena(x) {
@@ -47,15 +47,17 @@ export const VariantRules = class ArenaRules extends ChessRules {
         moves.push(this.getBasicMove([x, y], [x + 2 * shiftX, y]));
       }
     }
-    // Captures
+    // Captures: also possible backward
     for (let shiftY of [-1, 1]) {
-      if (
-        y + shiftY >= 0 &&
-        y + shiftY < sizeY &&
-        this.board[x + shiftX][y + shiftY] != V.EMPTY &&
-        this.canTake([x, y], [x + shiftX, y + shiftY])
-      ) {
-        moves.push(this.getBasicMove([x, y], [x + shiftX, y + shiftY]));
+      if (y + shiftY >= 0 && y + shiftY < sizeY) {
+        for (let direction of [-1,1]) {
+          if (
+            this.board[x + direction][y + shiftY] != V.EMPTY &&
+            this.canTake([x, y], [x + direction, y + shiftY])
+          ) {
+            moves.push(this.getBasicMove([x, y], [x + direction, y + shiftY]));
+          }
+        }
       }
     }
 
@@ -149,4 +151,8 @@ export const VariantRules = class ArenaRules extends ChessRules {
     }
     return "*";
   }
+
+  static get SEARCH_DEPTH() {
+    return 4;
+  }
 };