From 2b133d3ed6b8b73a0d7523b0603f87ad3b1eaf44 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Jakse?= Date: Sat, 4 Apr 2020 16:51:45 +0200 Subject: [PATCH] Store when a game was last updated --- trivabble-server.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/trivabble-server.js b/trivabble-server.js index 21b3140..04c333b 100644 --- a/trivabble-server.js +++ b/trivabble-server.js @@ -168,6 +168,7 @@ Game.prototype.init = function () { this.remainingLetters = this.bag.length; this.racks = {}; this.scores = {}; + this.lastUpdated = new Date(); }; Game.prototype.toJSON = function () { @@ -176,7 +177,8 @@ Game.prototype.toJSON = function () { board: this.board, bag: this.bag, racks: this.racks, - scores: this.scores + scores: this.scores, + lastUpdated: this.lastUpdated.toISOString() }; }; @@ -187,6 +189,7 @@ Game.fromJSON = function (obj) { game.remainingLetters = obj.remainingLetters || game.bag.length; game.racks = obj.racks || {}; game.scores = obj.scores || {}; + game.lastUpdated = obj.lastUpdated ? new Date(obj.lastUpdated) : new Date(); return game; }; @@ -407,6 +410,8 @@ function handleCommand(cmd, gameNumber, playerName, response) { return; } + game.lastUpdated = new Date(); + var rack = null; switch (cmd.cmd) { -- 2.30.2