Fix Antiking
[xogo.git] / variants / Suction / class.js
index dbaefa0..cf5ae16 100644 (file)
@@ -44,9 +44,12 @@ export default class SuctionRules extends ChessRules {
   genRandInitFen(seed) {
     const options = Object.assign({mode: "suicide"}, this.options);
     const gr = new GiveawayRules({options: options, genFenOnly: true});
+    const baseFen = gr.genRandInitFen(seed);
     // Add empty cmove:
-    return (
-      gr.genRandInitFen(seed).slice(0, -17) + '{"enpassant":"-","cmove":"-"}');
+    const fenParts = baseFen.split(" ");
+    let others = JSON.parse(fenParts[3]);
+    others["cmove"] = "-";
+    return fenParts.slice(0, 3).join(" ") + " " + JSON.stringify(others);
   }
 
   getFen() {
@@ -104,8 +107,8 @@ export default class SuctionRules extends ChessRules {
   getCurrentScore() {
     const color = this.turn;
     const kingPos = super.searchKingPos(color);
-    if (color == "w" && kingPos[0] == 0) return "0-1";
-    if (color == "b" && kingPos[0] == this.size.x - 1) return "1-0";
+    if (color == "w" && kingPos[0][0] == 0) return "0-1";
+    if (color == "b" && kingPos[0][0] == this.size.x - 1) return "1-0";
     // King is not on the opposite edge: game not over
     return "*";
   }