Generalize pawn movements: cleaner and smaller code
[vchess.git] / client / src / variants / Dark.js
index 81f8700..3bca234 100644 (file)
@@ -2,7 +2,7 @@ import { ChessRules } from "@/base_rules";
 import { ArrayFun } from "@/utils/array";
 import { randInt } from "@/utils/alea";
 
-export const VariantRules = class DarkRules extends ChessRules {
+export class DarkRules extends ChessRules {
   // Analyse in Dark mode makes no sense
   static get CanAnalyze() {
     return false;
@@ -78,6 +78,11 @@ export const VariantRules = class DarkRules extends ChessRules {
     }
   }
 
+  filterValid(moves) {
+    // Used in the interface
+    return moves;
+  }
+
   // Has to be redefined to avoid an infinite loop
   getAllValidMoves() {
     const color = this.turn;
@@ -98,8 +103,8 @@ export const VariantRules = class DarkRules extends ChessRules {
     return [];
   }
 
-  updateVariables(move) {
-    super.updateVariables(move);
+  postPlay(move) {
+    super.postPlay(move);
     if (move.vanish.length >= 2 && move.vanish[1].p == V.KING)
       // We took opponent king (because if castle vanish[1] is a rook)
       this.kingPos[this.turn] = [-1, -1];
@@ -108,8 +113,8 @@ export const VariantRules = class DarkRules extends ChessRules {
     this.updateEnlightened();
   }
 
-  unupdateVariables(move) {
-    super.unupdateVariables(move);
+  postUndo(move) {
+    super.postUndo(move);
     const c = move.vanish[0].c;
     const oppCol = V.GetOppCol(c);
     if (this.kingPos[oppCol][0] < 0)