Better Schess notation when introducing pieces while castling
[vchess.git] / client / src / variants / Pandemonium.js
index f4ae3c4..af87b27 100644 (file)
@@ -223,6 +223,7 @@ export class PandemoniumRules extends ChessRules {
 
   getReserveMoves([x, y]) {
     const color = this.turn;
+    const oppCol = V.GetOppCol(color);
     const p = V.RESERVE_PIECES[y];
     if (this.reserve[color][p] == 0) return [];
     const bounds = (p == V.PAWN ? [1, V.size.x - 1] : [0, V.size.x]);
@@ -541,7 +542,7 @@ export class PandemoniumRules extends ChessRules {
     const steps =
       V.steps[V.KNIGHT].concat(V.steps[V.ROOK]).concat(V.steps[V.BISHOP]);
     return (
-      super.isAttackedBySlideNJump(sq, color, steps, V.SCEPTER, "oneStep")
+      super.isAttackedBySlideNJump(sq, color, V.SCEPTER, steps, "oneStep")
     );
   }
 
@@ -549,7 +550,7 @@ export class PandemoniumRules extends ChessRules {
     return (
       super.isAttackedBySlideNJump(sq, color, V.steps[V.BISHOP], V.HORSE) ||
       super.isAttackedBySlideNJump(
-        sq, color, V.steps[V.ROOK], V.HORSE, "oneStep")
+        sq, color, V.HORSE, V.steps[V.ROOK], "oneStep")
     );
   }
 
@@ -557,7 +558,7 @@ export class PandemoniumRules extends ChessRules {
     return (
       super.isAttackedBySlideNJump(sq, color, V.steps[V.ROOK], V.DRAGON) ||
       super.isAttackedBySlideNJump(
-        sq, color, V.steps[V.BISHOP], V.DRAGON, "oneStep")
+        sq, color, V.DRAGON, V.steps[V.BISHOP], "oneStep")
     );
   }
 
@@ -648,7 +649,7 @@ export class PandemoniumRules extends ChessRules {
   }
 
   updateCastleFlags(move, piece) {
-    if (move.appear.length == 2) {
+    if (piece == V.KING && move.appear.length == 2) {
       // Castling (only move which disable flags)
       this.castleFlags[move.appear[0].c][0] = 10;
       this.castleFlags[move.appear[0].c][1] = 10;
@@ -722,7 +723,10 @@ export class PandemoniumRules extends ChessRules {
 
   static get VALUES() {
     return Object.assign(
+      {},
+      ChessRules.VALUES,
       {
+        n: 2.5, //knight is weaker
         g: 9,
         s: 5,
         h: 6,
@@ -731,8 +735,7 @@ export class PandemoniumRules extends ChessRules {
         w: 9,
         m: 8,
         a: 9
-      },
-      ChessRules.VALUES
+      }
     );
   }