From d385f8830e749a3baeae2a411c85f0fadffbefe5 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Thu, 7 Jan 2021 12:33:36 -0700 Subject: [PATCH] Implement toJSON method. --- server/src/objects/Game.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/server/src/objects/Game.ts b/server/src/objects/Game.ts index 20f7ba5..97947db 100644 --- a/server/src/objects/Game.ts +++ b/server/src/objects/Game.ts @@ -107,11 +107,22 @@ export class Game { }; - public toJSON() { + public toJSON(): datastoreGame { /** * Returns a JSON representation of the game. */ - let players = this.players.map(p => p.toJSON()); + return { + players: this.players.map(p => p.toJSON()), + teams: this.teams.map(t => t.toJSON()), + decks: { + questions: this._questions.toJSON(), + objects: this._objects.toJSON(), + }, + objectCard: this._objectCard, + object: this.object, + ingame: this.ingame, + id: this.id, + }; }; public static fromJSON() {