Skip to content
Snippets Groups Projects
Commit 063d7e98 authored by L4168's avatar L4168
Browse files

replay returns drawings and gamedata

parent 1e08bac0
No related branches found
No related tags found
3 merge requests!59Development to master,!54Development to testing,!53Mapdrawing replay
...@@ -56,6 +56,14 @@ export class ReplayService { ...@@ -56,6 +56,14 @@ export class ReplayService {
} */ } */
async replayData(gameId) { async replayData(gameId) {
//
// this block returns game's initial location
//
let gameObj = await this.gameRepository.findOne({
where: { id: gameId },
select: ['center'],
});
let gamelocation = [gameObj.center.lat, gameObj.center.lng];
// //
// this block returns all player data from the game // this block returns all player data from the game
// //
...@@ -111,11 +119,28 @@ export class ReplayService { ...@@ -111,11 +119,28 @@ export class ReplayService {
); );
}), }),
); );
//
// this block returns all map drawings from the game
//
let refs = await this.mapdrawingRepository.find({
where: { gameId: gameId },
select: ['mapDrawingId'],
});
let drawData = await Promise.all(
refs.map(async ref => {
return await this.mapHistoryRepository.find({
where: { mapdrawing: ref.mapDrawingId },
});
}),
);
return { return {
location: gamelocation,
players: currentdata, players: currentdata,
factions: currentFactions, factions: currentFactions,
scores: currentScore, scores: currentScore,
drawings: drawData,
}; };
} }
// generate mockdata for a 3 day game // generate mockdata for a 3 day game
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment