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;
};