Generalize pawn movements: cleaner and smaller code
[vchess.git] / client / src / variants / Grasshopper.js
index ec52d9b..fb8c27c 100644 (file)
@@ -2,11 +2,22 @@ import { ChessRules } from "@/base_rules";
 import { ArrayFun } from "@/utils/array";
 import { randInt } from "@/utils/alea";
 
-export const VariantRules = class GrasshopperRules extends ChessRules {
+export class GrasshopperRules extends ChessRules {
   static get HasEnpassant() {
     return false;
   }
 
+  static get PawnSpecs() {
+    return Object.assign(
+      {},
+      ChessRules.PawnSpecs,
+      {
+        twoSquares: false,
+        promotions: ChessRules.PawnSpecs.promotions.concat([V.GRASSHOPPER])
+      }
+    );
+  }
+
   static get GRASSHOPPER() {
     return "g";
   }