From: Raphaƫl Jakse Date: Sat, 4 Apr 2020 14:51:45 +0000 (+0200) Subject: Store when a game was last updated X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=2b133d3ed6b8b73a0d7523b0603f87ad3b1eaf44;p=trivabble.git Store when a game was last updated --- 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) {