Fix Dynamo variant
[vchess.git] / client / src / variants / Sittuyin.js
index 23ffcee..ccdd7b2 100644 (file)
@@ -195,7 +195,7 @@ export class SittuyinRules extends ChessRules {
       addPromotion([x - shiftX, y]);
       for (let step of V.steps[V.BISHOP]) {
         const [i, j] = [x + step[0], y + step[1]];
-        if (V.OnBoard(i, j) && this.board[i][j] != V.EMPTY)
+        if (V.OnBoard(i, j) && this.board[i][j] == V.EMPTY)
           addPromotion([i, j], "moveTo");
       }
     }
@@ -311,7 +311,15 @@ export class SittuyinRules extends ChessRules {
   getNotation(move) {
     // Do not note placement moves (complete move would be too long)
     if (move.vanish.length == 0) return "";
+    if (move.appear[0].p != move.vanish[0].p) {
+      // Pawn promotion: indicate correct final square
+      const initSquare =
+        V.CoordsToSquare({ x: move.vanish[0].x, y: move.vanish[0].y })
+      const destSquare =
+        V.CoordsToSquare({ x: move.appear[0].x, y: move.appear[0].y })
+      const prefix = (initSquare != destSquare ? initSquare : "");
+      return prefix + destSquare + "=Q";
+    }
     return super.getNotation(move);
   }
 };
-