Pass result to Hall after a game ends
authorBenjamin Auder <benjamin.auder@somewhere>
Thu, 13 Feb 2020 14:05:36 +0000 (15:05 +0100)
committerBenjamin Auder <benjamin.auder@somewhere>
Thu, 13 Feb 2020 14:05:36 +0000 (15:05 +0100)
client/src/views/Game.vue
client/src/views/Hall.vue
server/sockets.js

index e83b988..062990d 100644 (file)
@@ -686,6 +686,8 @@ export default {
       {
         GameStorage.update(this.gameRef.id,
           {score: score, scoreMsg: scoreMsg});
+        // Notify the score to main Hall. TODO: only one player (currently double send)
+        this.send("result", {gid:this.game.id, score:score});
       }
     },
   },
index de6d6d1..9b58409 100644 (file)
@@ -548,6 +548,13 @@ export default {
           }
           break;
         }
+        case "result":
+        {
+          let g = this.games.find(g => g.id == data.gid);
+          if (!!g)
+            g.score = data.score;
+          break;
+        }
         case "startgame":
         {
           // New game just started: data contain all information
index 7f0d14e..3fb7ea2 100644 (file)
@@ -186,6 +186,11 @@ module.exports = function(wss) {
           notifyRoom(page, obj.code, {data:obj.data});
           break;
 
+        case "result":
+          // Special case: notify all, 'transroom': Game --> Hall
+          notifyRoom("/", "result", {gid:obj.gid, score:obj.score});
+          break;
+
         // Passing, relaying something: from isn't needed,
         // but target is fully identified (sid + tmpId)
         case "challenge":