Add unambiguous section in the PGN + some fixes + code formatting and fix typos
[vchess.git] / client / src / variants / Crazyhouse.js
index fb8c744..a133b27 100644 (file)
@@ -1,7 +1,7 @@
 import { ChessRules, PiPo, Move } from "@/base_rules";
 import { ArrayFun } from "@/utils/array";
 
-export const VariantRules = class CrazyhouseRules extends ChessRules {
+export class CrazyhouseRules extends ChessRules {
   static IsGoodFen(fen) {
     if (!ChessRules.IsGoodFen(fen)) return false;
     const fenParsed = V.ParseFen(fen);
@@ -22,17 +22,13 @@ export const VariantRules = class CrazyhouseRules extends ChessRules {
 
   static ParseFen(fen) {
     const fenParts = fen.split(" ");
-    return Object.assign(ChessRules.ParseFen(fen), {
-      reserve: fenParts[5],
-      promoted: fenParts[6]
-    });
-  }
-
-  getEpSquare(moveOrSquare) {
-    if (typeof moveOrSquare !== "object" || moveOrSquare.vanish.length > 0)
-      return super.getEpSquare(moveOrSquare);
-    // Landing move: no en-passant
-    return undefined;
+    return Object.assign(
+      ChessRules.ParseFen(fen),
+      {
+        reserve: fenParts[5],
+        promoted: fenParts[6]
+      }
+    );
   }
 
   static GenRandInitFen(randomness) {
@@ -202,7 +198,8 @@ export const VariantRules = class CrazyhouseRules extends ChessRules {
 
   postPlay(move) {
     super.postPlay(move);
-    if (move.vanish.length == 2 && move.appear.length == 2) return; //skip castle
+    // Skip castle:
+    if (move.vanish.length == 2 && move.appear.length == 2) return;
     const color = move.appear[0].c;
     if (move.vanish.length == 0) {
       this.reserve[color][move.appear[0].p]--;