From: Benjamin Auder Date: Thu, 13 Feb 2020 14:05:36 +0000 (+0100) Subject: Pass result to Hall after a game ends X-Git-Url: https://git.auder.net/variants/Chakart/doc/scripts/img/pieces/cp.svg?a=commitdiff_plain;h=48ab808f1454463ca2b960d6301fa0f47f21b4ad;p=vchess.git Pass result to Hall after a game ends --- diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index e83b9886..062990d2 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -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}); } }, }, diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index de6d6d15..9b584095 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -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 diff --git a/server/sockets.js b/server/sockets.js index 7f0d14ec..3fb7ea2a 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -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":