Skip to content
Snippets Groups Projects
Commit 1d21c6ef authored by L4168's avatar L4168
Browse files

playerdata returns username&role

parent 375c01f0
No related branches found
No related tags found
3 merge requests!59Development to master,!54Development to testing,!49Replay update
......@@ -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,
......
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