Fix FenUtil.setupPieces and Antiking variants
[xogo.git] / variants / Ambiguous / class.js
index 6d9ac7e..6a83374 100644 (file)
@@ -1,5 +1,5 @@
 import ChessRules from "/base_rules.js";
-import GiveawayRules from "/variants/Giveaway/class.js";
+import {FenUtil} from "/utils/setupPieces.js";
 
 export default class AmbiguousRules extends ChessRules {
 
@@ -23,9 +23,18 @@ export default class AmbiguousRules extends ChessRules {
   }
 
   genRandInitBaseFen() {
-    const options = Object.assign({mode: "suicide"}, this.options);
-    const gr = new GiveawayRules({options: options, genFenOnly: true});
-    return gr.genRandInitBaseFen();
+    const s = FenUtil.setupPieces(
+      ['r', 'n', 'b', 'q', 'k', 'b', 'n', 'r'],
+      {
+        randomness: this.options["randomness"],
+        diffCol: ['b']
+      }
+    );
+    return {
+      fen: s.b.join("") + "/pppppppp/8/8/8/8/PPPPPPPP/" +
+           s.w.join("").toUpperCase(),
+      o: {}
+    };
   }
 
   canStepOver(x, y) {
@@ -124,12 +133,12 @@ export default class AmbiguousRules extends ChessRules {
 
   pieces(color, x, y) {
     const targets = {
-      's': {"class": "target-pawn", moves: []},
-      'u': {"class": "target-rook", moves: []},
-      'o': {"class": "target-knight", moves: []},
-      'c': {"class": "target-bishop", moves: []},
-      't': {"class": "target-queen", moves: []},
-      'l': {"class": "target-king", moves: []}
+      's': {"class": "target-pawn"},
+      'u': {"class": "target-rook"},
+      'o': {"class": "target-knight"},
+      'c': {"class": "target-bishop"},
+      't': {"class": "target-queen"},
+      'l': {"class": "target-king"}
     };
     return Object.assign({ 'g': {"class": "target"} },
       targets, super.pieces(color, x, y));