From a550511adb077ee08686934f67c64b0832d2bb36 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sun, 25 Apr 2021 09:32:33 +0200
Subject: [PATCH] Fix Synochess

---
 client/src/variants/Synochess.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/client/src/variants/Synochess.js b/client/src/variants/Synochess.js
index 74eecace..aa758760 100644
--- a/client/src/variants/Synochess.js
+++ b/client/src/variants/Synochess.js
@@ -475,7 +475,7 @@ export class SynochessRules extends ChessRules {
 
   updateCastleFlags(move, piece) {
     // Only white can castle:
-    const firstRank = 0;
+    const firstRank = 7;
     if (piece == V.KING && move.appear[0].c == 'w')
       this.castleFlags['w'] = [8, 8];
     else if (
@@ -495,18 +495,19 @@ export class SynochessRules extends ChessRules {
   }
 
   postPlay(move) {
-    super.postPlay(move);
     // After black move, turn == 'w':
-    if (!!this.reserve && this.turn == 'w' && move.vanish.length == 0)
+    if (!!this.reserve && this.turn == 'w' && move.vanish.length == 0) {
       if (--this.reserve['b'][V.SOLDIER] == 0) this.reserve = null;
+    }
+    else super.postPlay(move);
   }
 
   postUndo(move) {
-    super.postUndo(move);
     if (this.turn == 'b' && move.vanish.length == 0) {
       if (!this.reserve) this.reserve = { 'b': { [V.SOLDIER]: 1 } };
       else this.reserve['b'][V.SOLDIER]++;
     }
+    else super.postUndo(move);
   }
 
   static get VALUES() {
@@ -533,4 +534,9 @@ export class SynochessRules extends ChessRules {
     return evaluation;
   }
 
+  getNotation(move) {
+    if (move.vanish.length == 0) return "@" + V.CoordsToSquare(move.end);
+    return super.getNotation(move);
+  }
+
 };
-- 
2.44.0