From d18bfa126e918ecc13f2a70612b1cfda25e1e25a Mon Sep 17 00:00:00 2001
From: Benjamin Auder <benjamin.auder@somewhere>
Date: Tue, 3 Dec 2019 20:42:19 +0100
Subject: [PATCH] A few fixes

---
 client/src/components/BaseGame.vue |  8 ++++----
 client/src/views/Game.vue          | 13 +++++++++++--
 client/src/views/Hall.vue          |  4 ++--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/client/src/components/BaseGame.vue b/client/src/components/BaseGame.vue
index 9f4b6df8..8e9ac36a 100644
--- a/client/src/components/BaseGame.vue
+++ b/client/src/components/BaseGame.vue
@@ -223,6 +223,8 @@ export default {
       this.lastMove = move;
       if (this.st.settings.sound == 2)
         new Audio("/sounds/move.mp3").play().catch(err => {});
+      if (!this.analyze)
+        this.$emit("newmove", move); //post-processing (e.g. computer play)
       if (!navigate)
       {
         move.fen = this.vr.getFen();
@@ -235,10 +237,10 @@ export default {
             this.moves = this.moves.slice(0,this.cursor).concat([move]);
         }
       }
-      // Is opponent in check? (TODO: generalize, find all check squares)
+      // Is opponent in check?
       this.incheck = this.vr.getCheckSquares(this.vr.turn);
       const score = this.vr.getCurrentScore();
-      if (score != "*") //TODO: generalize score for 3 or 4 players
+      if (score != "*")
       {
         if (!this.analyze)
           this.endGame(score);
@@ -249,8 +251,6 @@ export default {
           this.showEndgameMsg(score + " . " + message);
         }
       }
-      if (!this.analyze)
-        this.$emit("newmove", move); //post-processing (e.g. computer play)
     },
     undo: function(move) {
       const navigate = !move;
diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue
index 923e9400..bd9125f2 100644
--- a/client/src/views/Game.vue
+++ b/client/src/views/Game.vue
@@ -97,7 +97,7 @@ export default {
       });
       const myTurn = (currentTurn == this.game.mycolor);
       let clockUpdate = setInterval(() => {
-        if (countdown <= 0 || this.vr.turn != currentTurn)
+        if (countdown <= 0 || this.vr.turn != currentTurn || this.game.score != "*")
         {
           clearInterval(clockUpdate);
           if (countdown <= 0 && myTurn)
@@ -334,7 +334,7 @@ export default {
           game.initime[0] = Date.now();
           if (myIdx >= 0) //I play in this game
           {
-            GameStorage.update(game.gameId,
+            GameStorage.update(game.id,
             {
               clocks: game.clocks,
               initime: game.initime,
@@ -344,6 +344,14 @@ export default {
         const vModule = await import("@/variants/" + vname + ".js");
         window.V = vModule.VariantRules;
         this.vr = new V(game.fen);
+        
+
+
+//TODO: people, on connect, search for opponent.......
+console.log(myIdx + " " + game.players[1-myIdx].sid); //otherwise this is undefined:
+
+
+
         this.game = Object.assign({},
           game,
           // NOTE: assign mycolor here, since BaseGame could also bs VS computer
@@ -433,6 +441,7 @@ export default {
     // TODO: this update function should also work for corr games
     gameOver: function(score) {
       this.game.mode = "analyze";
+      this.game.score = score;
       GameStorage.update(this.gameRef.id, { score: score });
     },
   },
diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue
index 433151c7..547395db 100644
--- a/client/src/views/Hall.vue
+++ b/client/src/views/Hall.vue
@@ -381,8 +381,8 @@ export default {
           else
           {
             this.infoMessage = "New game started: " +
-              "<a href='/game/" + data.gameInfo.gameId + "'>" +
-              "/game/" + data.gameInfo.gameId + "</a>";
+              "<a href='#/game/" + data.gameInfo.gameId + "'>" +
+              "#/game/" + data.gameInfo.gameId + "</a>";
             let modalBox = document.getElementById("modalInfo");
             modalBox.checked = true;
             setTimeout(() => { modalBox.checked = false; }, 3000);
-- 
2.44.0