diff --git a/src/replay/replay.service.ts b/src/replay/replay.service.ts index dcc9738cc512bba9e3a257e06ec5f8f539b07c01..76803d53d827479c5256fb1a74bf6410ca55ab4f 100644 --- a/src/replay/replay.service.ts +++ b/src/replay/replay.service.ts @@ -54,16 +54,19 @@ export class ReplayService { async getPlayers(gameId) { let playerdata = await this.trackingRepository.find({ where: { game: gameId }, - relations: ['faction', 'gamepersonId'], + relations: ['faction', 'gamepersonId', 'gamepersonId.person'], }); - // parse data const currentdata = await Promise.all( playerdata.map(async player => { - player['data'][0]['info'] = [ - { key: 'icon', value: player.icon }, - { key: 'colour', value: player.faction.colour }, - ]; + player.data.map(async data => { + data['info'] = [ + { key: 'icon', value: player.icon }, + { key: 'colour', value: player.faction.colour }, + { key: 'name', value: player.gamepersonId.person.name }, + { key: 'role', value: player.gamepersonId.role }, + ]; + }); return player['data']; }), ); @@ -79,11 +82,11 @@ export class ReplayService { relations: ['factions'], }); const groups = await this.factionService.showGroups( - game.factions[0].factionId, + game.factions[1].factionId, ); for (let i = 0; i < 100; i++) { let res = await this.userService.register({ - name: 'asdf' + i, + name: 'asdfasa' + i, password: 'asd', }); let user = await jwt.verify(res.token, process.env.SECRET); @@ -98,8 +101,8 @@ export class ReplayService { game: gameId, }); */ let gameperson = await this.factionService.joinFaction(user['id'], { - factionId: game.factions[0].factionId, - factionPassword: game.factions[0].factionPassword, + factionId: game.factions[1].factionId, + factionPassword: game.factions[1].factionPassword, game: gameId, }); await this.factionService.joinGroup(gameperson, { @@ -109,9 +112,9 @@ export class ReplayService { } let date: number = Date.now(); let y1 = 25.7; - let x1 = 62.3; + let x1 = 62.0; let y2 = 25.75; - let x2 = 62.35; + let x2 = 62.05; for (let i = 1; i < 6; i++) { let x = 0; date += 10000; @@ -120,11 +123,11 @@ export class ReplayService { x++; let dataObject = { lat: - x < 10 + x < 50 ? x1 + ((i + Math.random()) * 5) / 2000 : x2 - ((i + Math.random()) * 5) / 2000, lng: - x < 10 + x < 50 ? y1 + ((i + Math.random()) * 5) / 2000 : y2 - ((i + Math.random()) * 5) / 2000, time: date,