Fix computer moves randomness, rename random() into randInt()
[vchess.git] / client / src / views / Game.vue
index 984a66b..2d085c8 100644 (file)
@@ -8,6 +8,7 @@
         h3#abortBoxTitle.section {{ st.tr["Terminate game?"] }}
         button(@click="abortGame") {{ st.tr["Sorry I have to go"] }}
         button(@click="abortGame") {{ st.tr["Game seems over"] }}
+        button(@click="abortGame") {{ st.tr["Opponent is gone"] }}
     BaseGame(:game="game" :vr="vr" ref="basegame"
       @newmove="processMove" @gameover="gameOver")
     div Names: {{ game.players[0].name }} - {{ game.players[1].name }}
@@ -189,7 +190,7 @@ export default {
           {
             // Minimal game informations:
             id: this.game.id,
-            players: this.game.players.map(p => p.name),
+            players: this.game.players.map(p => { return {name:p.name}; }),
             vid: this.game.vid,
             timeControl: this.game.timeControl,
           };
@@ -512,7 +513,11 @@ export default {
     gameOver: function(score) {
       this.game.mode = "analyze";
       this.game.score = score;
-      GameStorage.update(this.gameRef.id, { score: score });
+      const myIdx = this.game.players.findIndex(p => {
+        return p.sid == this.st.user.sid || p.uid == this.st.user.id;
+      });
+      if (myIdx >= 0) //OK, I play in this game
+        GameStorage.update(this.gameRef.id, { score: score });
     },
   },
 };