Fix Spartan Chess: warlord attacks now detected
[vchess.git] / client / src / variants / Spartan.js
index 3b4fc77..2400e04 100644 (file)
@@ -12,8 +12,7 @@ export class SpartanRules extends ChessRules {
   }
 
   getPpath(b) {
-    if ([V.LIEUTENANT, V.GENERAL, V.CAPTAIN, V.WARLORD].includes(b[1]))
-      return "Spartan/" + b;
+    if (b[0] == 'b' && b[1] != 'k') return "Spartan/" + b;
     return b;
   }
 
@@ -275,9 +274,9 @@ export class SpartanRules extends ChessRules {
 
   isAttackedByWarlord(sq) {
     return (
-      super.isAttackedBySlideNJump(sq, 'b', V.GENERAL,
-        V.steps[V.ROOK].concat(V.steps[V.BISHOP]), "oneStep") ||
-      super.isAttackedBySlideNJump(sq, 'b', V.GENERAL, V.steps[V.ROOK])
+      super.isAttackedBySlideNJump(
+        sq, 'b', V.WARLORD, V.steps[V.KNIGHT], "oneStep") ||
+      super.isAttackedBySlideNJump(sq, 'b', V.WARLORD, V.steps[V.BISHOP])
     );
   }