From ef32d90030257cee10fa68eb259c760c87e5fa13 Mon Sep 17 00:00:00 2001 From: Anthony Mineo Date: Sun, 30 Aug 2020 10:00:33 -0400 Subject: [PATCH] Return formatted stats based off other gameTypes --- app/api/src/game/game.service.ts | 35 +++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/app/api/src/game/game.service.ts b/app/api/src/game/game.service.ts index 00cc961..b37cc41 100644 --- a/app/api/src/game/game.service.ts +++ b/app/api/src/game/game.service.ts @@ -25,19 +25,34 @@ export class GameService { throw new NotFoundException(`Game ID: ${gameId} not found`); } - // Need to set return based off gameType + const game: any = { + ...query[0].game + }; - if (query[0].gametype !== 'CTFGame') { - return query; + // Need to set return based off gameType + // Modify game object if not a CTF type game and return early + if (query[0].gametype !== 'CTFGame' && query[0].gametype !== 'SCtFGame') { + game['players'] = []; + for (const player of query) { + const { playerName, stats } = player; + + const p = { + playerGuid: player.playerGuid.playerGuid, + playerName, + stats + }; + + game.players.push(p); + } + + return game; } - const game: any = { - ...query[0].game, - teams: { - obs: { score: 0, players: [] }, - storm: { score: 0, players: [] }, - inferno: { score: 0, players: [] } - } + // Team Based game stats (CTF/SCtF) + game['teams'] = { + obs: { score: 0, players: [] }, + storm: { score: 0, players: [] }, + inferno: { score: 0, players: [] } }; for (const player of query) {