Draft Coregal variant - still getCastleMoves() and updateCastleFlags() TODO
[vchess.git] / client / src / variants / Wildebeest.js
index bf5c178..5bb50e8 100644 (file)
@@ -2,7 +2,7 @@ import { ChessRules } from "@/base_rules";
 import { ArrayFun } from "@/utils/array";
 import { sample, randInt } from "@/utils/alea";
 
-export const VariantRules = class WildebeestRules extends ChessRules {
+export class WildebeestRules extends ChessRules {
   static get size() {
     return { x: 10, y: 11 };
   }
@@ -196,28 +196,28 @@ export const VariantRules = class WildebeestRules extends ChessRules {
     );
   }
 
-  isAttacked(sq, colors) {
+  isAttacked(sq, color) {
     return (
-      super.isAttacked(sq, colors) ||
-      this.isAttackedByCamel(sq, colors) ||
-      this.isAttackedByWildebeest(sq, colors)
+      super.isAttacked(sq, color) ||
+      this.isAttackedByCamel(sq, color) ||
+      this.isAttackedByWildebeest(sq, color)
     );
   }
 
-  isAttackedByCamel(sq, colors) {
+  isAttackedByCamel(sq, color) {
     return this.isAttackedBySlideNJump(
       sq,
-      colors,
+      color,
       V.CAMEL,
       V.steps[V.CAMEL],
       "oneStep"
     );
   }
 
-  isAttackedByWildebeest(sq, colors) {
+  isAttackedByWildebeest(sq, color) {
     return this.isAttackedBySlideNJump(
       sq,
-      colors,
+      color,
       V.WILDEBEEST,
       V.steps[V.KNIGHT].concat(V.steps[V.CAMEL]),
       "oneStep"
@@ -225,10 +225,7 @@ export const VariantRules = class WildebeestRules extends ChessRules {
   }
 
   getCurrentScore() {
-    if (this.atLeastOneMove())
-      // game not over
-      return "*";
-
+    if (this.atLeastOneMove()) return "*";
     // No valid move: game is lost (stalemate is a win)
     return this.turn == "w" ? "0-1" : "1-0";
   }