Remove information about the bag being suffled
authorRaphaël Jakse <raphael.trivabble@jakse.fr>
Wed, 15 Apr 2020 22:28:15 +0000 (00:28 +0200)
committerRaphaël Jakse <raphael.trivabble@jakse.fr>
Wed, 15 Apr 2020 22:28:15 +0000 (00:28 +0200)
trivabble-server.js

index f88b4bfb415219265ebe4b1b26c205b364988f5f..680df2dbc4f79c3ac72eb0e412bc1e1b348212e5 100644 (file)
@@ -272,29 +272,17 @@ Game.prototype.toJSON = function () {
         bag:              this.bag,
         racks:            this.racks,
         scores:           this.scores,
-        lastUpdated:      this.lastUpdated.toISOString(),
-        bagShuffled:      true // Will be gone soon, needed for compatibility with saved games
+        lastUpdated:      this.lastUpdated.toISOString()
     };
 };
 
 Game.fromJSON = function (obj) {
-    // WARNING: modifies the passed parameter because of the suffling.
-    // This is harmless here, and temporary anyway.
-    // Variable bagShuffled is soon to be gone.
-
     const game = new Game();
     game.board            = obj.board  || newBoard();
     game.bag              = obj.bag    || frBag.slice();
     game.racks            = obj.racks  || {};
     game.scores           = obj.scores || {};
     game.lastUpdated      = obj.lastUpdated ? new Date(obj.lastUpdated) : new Date();
-
-    // To delete soon
-    if (!obj.bagShuffled) {
-        game.bag = game.bag.filter((tile) => tile !== "");
-        shuffleInPlace(game.bag);
-    }
-
     return game;
 };