Several small improvements + integrate options + first working draft of Cwda
[vchess.git] / client / src / variants / Pawnmassacre.js
index 563fd00..c08b585 100644 (file)
@@ -1,18 +1,29 @@
 import { ChessRules } from "@/base_rules";
 
 export class PawnmassacreRules extends ChessRules {
+
   static get HasFlags() {
     return false;
   }
 
-  static GenRandInitFen(randomness) {
-    return (
-      ChessRules.GenRandIntFen(randomness)
+  get showFirstTurn() {
+    return true;
+  }
+
+  static GenRandInitFen(options) {
+    const bFen =
+      ChessRules.GenRandInitFen(options)
       // Remove castle flags
-      .slice(0, -6).concat("-")
+      .slice(0, -6).concat("-");
+    const splitIdx = bFen.indexOf(' ');
+    return (
+      bFen.substr(0, splitIdx)
       .replace("PPPPPPPP", "pppppppp")
       // Next replacement is OK because only acts on first occurrence
       .replace("pppppppp", "PPPPPPPP")
+      .split("").reverse().join("")
+      .concat(bFen.substr(splitIdx))
     );
   }
+
 };