From 3cf543959e84a8a5aa3f39f4f294790e2050b3b6 Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Sun, 3 Jan 2021 16:20:31 +0100
Subject: [PATCH] Slightly less buggish Paco-Sako

---
 client/src/base_rules.js                      | 1 +
 client/src/translations/rules/Pacosako/en.pug | 2 +-
 client/src/translations/rules/Pacosako/es.pug | 2 +-
 client/src/translations/rules/Pacosako/fr.pug | 2 +-
 client/src/translations/variants/es.pug       | 1 +
 client/src/translations/variants/fr.pug       | 1 +
 client/src/variants/Pacosako.js               | 5 ++---
 7 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/client/src/base_rules.js b/client/src/base_rules.js
index e91a43e8..770561bd 100644
--- a/client/src/base_rules.js
+++ b/client/src/base_rules.js
@@ -1071,6 +1071,7 @@ export const ChessRules = class ChessRules {
       }
       if (
         V.OnBoard(rx, ry) &&
+        this.board[rx][ry] != V.EMPTY &&
         this.getPiece(rx, ry) == piece &&
         this.getColor(rx, ry) == color
       ) {
diff --git a/client/src/translations/rules/Pacosako/en.pug b/client/src/translations/rules/Pacosako/en.pug
index 6fe1bc10..371b00b8 100644
--- a/client/src/translations/rules/Pacosako/en.pug
+++ b/client/src/translations/rules/Pacosako/en.pug
@@ -8,6 +8,6 @@ p
   a(href="https://www.youtube.com/watch?v=tQ2JLsFvfxI") Video
   | &nbsp;showing gameplay. See also 
   a(href="http://pacosako.com/") the main website
-  | , and the associated
+  | , and the associated 
   a(href="http://pacoplay.com/") playing area
   | .
diff --git a/client/src/translations/rules/Pacosako/es.pug b/client/src/translations/rules/Pacosako/es.pug
index 6fe1bc10..371b00b8 100644
--- a/client/src/translations/rules/Pacosako/es.pug
+++ b/client/src/translations/rules/Pacosako/es.pug
@@ -8,6 +8,6 @@ p
   a(href="https://www.youtube.com/watch?v=tQ2JLsFvfxI") Video
   | &nbsp;showing gameplay. See also 
   a(href="http://pacosako.com/") the main website
-  | , and the associated
+  | , and the associated 
   a(href="http://pacoplay.com/") playing area
   | .
diff --git a/client/src/translations/rules/Pacosako/fr.pug b/client/src/translations/rules/Pacosako/fr.pug
index 6fe1bc10..371b00b8 100644
--- a/client/src/translations/rules/Pacosako/fr.pug
+++ b/client/src/translations/rules/Pacosako/fr.pug
@@ -8,6 +8,6 @@ p
   a(href="https://www.youtube.com/watch?v=tQ2JLsFvfxI") Video
   | &nbsp;showing gameplay. See also 
   a(href="http://pacosako.com/") the main website
-  | , and the associated
+  | , and the associated 
   a(href="http://pacoplay.com/") playing area
   | .
diff --git a/client/src/translations/variants/es.pug b/client/src/translations/variants/es.pug
index 97e528da..0f7ac86b 100644
--- a/client/src/translations/variants/es.pug
+++ b/client/src/translations/variants/es.pug
@@ -411,6 +411,7 @@ p.
     "Gridolina",
     "Hamilton",
     "Magnetic",
+    "Pacosako",
     "Parachute",
     "Takenmake",
     "Titan",
diff --git a/client/src/translations/variants/fr.pug b/client/src/translations/variants/fr.pug
index 950700da..53fcc16f 100644
--- a/client/src/translations/variants/fr.pug
+++ b/client/src/translations/variants/fr.pug
@@ -410,6 +410,7 @@ p.
     "Gridolina",
     "Hamilton",
     "Magnetic",
+    "Pacosako",
     "Parachute",
     "Takenmake",
     "Titan",
diff --git a/client/src/variants/Pacosako.js b/client/src/variants/Pacosako.js
index 430cfb0a..e935240c 100644
--- a/client/src/variants/Pacosako.js
+++ b/client/src/variants/Pacosako.js
@@ -120,9 +120,6 @@ export class PacosakoRules extends ChessRules {
 
   getPiece(i, j, color) {
     const p = this.board[i][j].charAt(1);
-
-console.log(p);
-
     if (ChessRules.PIECES.includes(p)) return p;
     const c = this.board[i][j].charAt(0);
     // NOTE: this.turn == HACK, but should work...
@@ -288,6 +285,7 @@ console.log(p);
       this.lastMoveEnd.push(Object.assign({}, move.end, { p: released }));
     }
     V.PlayOnBoard(this.board, move);
+    this.postPlay(move);
   }
 
   undo(move) {
@@ -298,6 +296,7 @@ console.log(p);
       this.turn = V.GetOppCol(this.turn);
       this.movesCount--;
     }
+    this.postUndo(move);
   }
 
   getCurrentScore() {
-- 
2.44.0