Add Antiking v1
[vchess.git] / client / src / variants / Shatranj.js
index c364b81..45a34c0 100644 (file)
@@ -5,6 +5,10 @@ export const VariantRules = class ShatranjRules extends ChessRules {
     return false;
   }
 
+  static get HasCastle() {
+    return false;
+  }
+
   static get HasEnpassant() {
     return false;
   }
@@ -90,28 +94,20 @@ export const VariantRules = class ShatranjRules extends ChessRules {
     );
   }
 
-  getPotentialKingMoves(sq) {
-    return this.getSlideNJumpMoves(
-      sq,
-      V.steps[V.ROOK].concat(V.steps[V.BISHOP]),
-      "oneStep"
-    );
-  }
-
-  isAttackedByBishop(sq, colors) {
+  isAttackedByBishop(sq, color) {
     return this.isAttackedBySlideNJump(
       sq,
-      colors,
+      color,
       V.BISHOP,
       V.ElephantSteps,
       "oneStep"
     );
   }
 
-  isAttackedByQueen(sq, colors) {
+  isAttackedByQueen(sq, color) {
     return this.isAttackedBySlideNJump(
       sq,
-      colors,
+      color,
       V.QUEEN,
       V.steps[V.BISHOP],
       "oneStep"
@@ -157,7 +153,7 @@ export const VariantRules = class ShatranjRules extends ChessRules {
       // 2 enemy units or more: I lose
       return getScoreLost();
     // I don't have any piece, my opponent have one: can I take it?
-    if (this.isAttacked(piecesLeft[oppCol].square, [color]))
+    if (this.isAttacked(piecesLeft[oppCol].square, color))
       // Yes! But I still need to take it
       return "*";
     // No :(