Add Brotherhood, Maharajah (special version) + Dobutsu variants
[vchess.git] / client / src / variants / Brotherhood.js
diff --git a/client/src/variants/Brotherhood.js b/client/src/variants/Brotherhood.js
new file mode 100644 (file)
index 0000000..4da4e11
--- /dev/null
@@ -0,0 +1,24 @@
+import { ChessRules } from "@/base_rules";
+
+export class BrotherhoodRules extends ChessRules {
+
+  getPotentialMovesFrom([x, y]) {
+    return (
+      super.getPotentialMovesFrom([x, y]).filter(m => {
+        // Forbid capturing same piece's type:
+        return (
+          m.vanish.length == 1 ||
+          [V.PAWN, V.KING].includes(m.vanish[0].p) ||
+          m.vanish[1].p != m.vanish[0].p
+        );
+      })
+    );
+  }
+
+  getCurrentScore() {
+    if (this.atLeastOneMove()) return "*";
+    // Game over
+    return (this.turn == "w" ? "0-1" : "1-0");
+  }
+
+};