Fix Swap variant
[vchess.git] / client / src / variants / Swap.js
index bf4e787..4d97ae9 100644 (file)
@@ -34,7 +34,7 @@ export class SwapRules extends ChessRules {
   }
 
   getPPpath(m) {
-    if (m.vanish.length == 1) return super.getPPpath(m);
+    if (m.appear.length == 1) return super.getPPpath(m);
     // Swap promotion:
     return m.appear[1].c + m.appear[1].p;
   }
@@ -71,7 +71,7 @@ export class SwapRules extends ChessRules {
     const color = this.turn;
     const piece = this.getPiece(x, y);
     const addSmoves = (i, j) => {
-      if (this.getPiece(i, j) != piece)
+      if (this.getPiece(i, j) != piece || this.getColor(i, j) != color)
         Array.prototype.push.apply(moves, this.getSwapMoves([x, y], [i, j]));
     };
     switch (piece) {