Generalize pawn movements: cleaner and smaller code
[vchess.git] / client / src / variants / Wildebeest.js
index bf5c178..8192fa0 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"