Fix Progressive2. Fixing attempt on Doublemove1
[vchess.git] / client / src / variants / Rifle.js
index 61c2c35..94a6d05 100644 (file)
@@ -1,11 +1,6 @@
 import { ChessRules, PiPo, Move } from "@/base_rules";
 
-export const VariantRules = class RifleRules extends ChessRules {
-  static get HasEnpassant() {
-    // Due to the capturing mode, en passant is disabled
-    return false;
-  }
-
+export class RifleRules extends ChessRules {
   getBasicMove([sx, sy], [ex, ey], tr) {
     let mv = new Move({
       appear: [],
@@ -46,4 +41,34 @@ export const VariantRules = class RifleRules extends ChessRules {
 
     return mv;
   }
+
+  getEnpassantCaptures([x, y], shiftX) {
+    let moves = [];
+    const Lep = this.epSquares.length;
+    const epSquare = this.epSquares[Lep - 1]; //always at least one element
+    if (
+      !!epSquare &&
+      epSquare.x == x + shiftX &&
+      Math.abs(epSquare.y - y) == 1
+    ) {
+      let enpassantMove = new Move({
+        appear: [],
+        vanish: [],
+        start: {x:x, y:y},
+        end: {x:x+shiftX, y:epSquare.y}
+      });
+      enpassantMove.vanish.push({
+        x: x,
+        y: epSquare.y,
+        p: "p",
+        c: this.getColor(x, epSquare.y)
+      });
+      moves.push(enpassantMove);
+    }
+    return moves;
+  }
+
+  static get SEARCH_DEPTH() {
+    return 2;
+  }
 };