Fix 1st move clocks don't move + add message to indicate that corr game started ...
authorBenjamin Auder <benjamin.auder@somewhere>
Mon, 2 Dec 2019 16:36:04 +0000 (17:36 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Mon, 2 Dec 2019 16:36:04 +0000 (17:36 +0100)
client/src/views/Game.vue
client/src/views/Hall.vue

index 2fdd223..f00dc92 100644 (file)
@@ -79,6 +79,12 @@ export default {
       }
     },
     "game.clocks": function(newState) {
       }
     },
     "game.clocks": function(newState) {
+      if (this.game.moves.length < 2)
+      {
+        // 1st move not completed yet: freeze time
+        this.virtualClocks = newState.map(s => ppt(s));
+        return;
+      }
       const currentTurn = this.vr.turn;
       const colorIdx = ["w","b"].indexOf(currentTurn);
       let countdown = newState[colorIdx] -
       const currentTurn = this.vr.turn;
       const colorIdx = ["w","b"].indexOf(currentTurn);
       let countdown = newState[colorIdx] -
@@ -380,12 +386,15 @@ export default {
           return obj;
         }, {});
       // Send move ("newmove" event) to opponent(s) (if ours)
           return obj;
         }, {});
       // Send move ("newmove" event) to opponent(s) (if ours)
-      let addTime = undefined;
+      let addTime = 0;
       if (move.color == this.game.mycolor)
       {
       if (move.color == this.game.mycolor)
       {
-        const elapsed = Date.now() - this.game.initime[colorIdx];
-        // elapsed time is measured in milliseconds
-        addTime = this.game.increment - elapsed/1000;
+        if (this.game.moves.length >= 2) //after first move
+        {
+          const elapsed = Date.now() - this.game.initime[colorIdx];
+          // elapsed time is measured in milliseconds
+          addTime = this.game.increment - elapsed/1000;
+        }
         this.st.conn.send(JSON.stringify({
           code: "newmove",
           target: this.game.oppid,
         this.st.conn.send(JSON.stringify({
           code: "newmove",
           target: this.game.oppid,
index c22c1e1..dadb597 100644 (file)
@@ -1,5 +1,11 @@
 <template lang="pug">
 main
 <template lang="pug">
 main
+  input#modalInfo.modal(type="checkbox")
+  div(role="dialog" aria-labelledby="infoMessage")
+    .card.smallpad.small-modal.text-center
+      label.modal-close(for="modalInfo")
+      h3#infoMessage.section
+        p New game started: #[a(href="/game/" + {{ newGameId }})]
   input#modalNewgame.modal(type="checkbox")
   div(role="dialog" aria-labelledby="titleFenedit")
     .card.smallpad
   input#modalNewgame.modal(type="checkbox")
   div(role="dialog" aria-labelledby="titleFenedit")
     .card.smallpad
@@ -85,6 +91,7 @@ export default {
       games: [],
       challenges: [],
       people: [], //(all) online players
       games: [],
       challenges: [],
       people: [], //(all) online players
+      newGameId: 0,
       newchallenge: {
         fen: "",
         vid: 0,
       newchallenge: {
         fen: "",
         vid: 0,
@@ -376,7 +383,10 @@ export default {
             this.startNewGame(data.gameInfo);
           else
           {
             this.startNewGame(data.gameInfo);
           else
           {
-            // TODO: notify with game link but do not redirect
+            this.newGameId = data.gameInfo.gameId;
+            let modalBox = document.getElementById("modalInfo");
+            modalBox.checked = true;
+            setTimeout(() => { modalBox.checked = false; }, 2500);
           }
           break;
         }
           }
           break;
         }