mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-07-13 23:34:34 +00:00
Calculated CTFGame return type stats
This commit is contained in:
parent
2fcfd8cb3b
commit
38fb66da06
1 changed files with 52 additions and 2 deletions
|
|
@ -16,13 +16,63 @@ export class GameService {
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async findOne(gameId: string) {
|
async findOne(gameId: string) {
|
||||||
const game = await this.gameRepository.find({
|
const query = await this.gameRepository.find({
|
||||||
relations: [ 'game', 'playerGuid' ],
|
relations: [ 'game', 'playerGuid' ],
|
||||||
where: [ { game: { gameId: gameId } } ]
|
where: [ { game: { gameId: gameId } } ]
|
||||||
});
|
});
|
||||||
if (!game) {
|
if (!query) {
|
||||||
throw new NotFoundException(`Game ID: ${gameId} not found`);
|
throw new NotFoundException(`Game ID: ${gameId} not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need to set return based off gameType
|
||||||
|
|
||||||
|
if (query[0].gametype !== 'CTFGame') {
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
const game: any = {
|
||||||
|
...query[0].game,
|
||||||
|
teams: {
|
||||||
|
obs: { score: 0, players: [] },
|
||||||
|
storm: { score: 0, players: [] },
|
||||||
|
inferno: { score: 0, players: [] }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const player of query) {
|
||||||
|
const { playerName, stats } = player;
|
||||||
|
|
||||||
|
const p = {
|
||||||
|
playerGuid: player.playerGuid.playerGuid,
|
||||||
|
playerName,
|
||||||
|
stats
|
||||||
|
};
|
||||||
|
|
||||||
|
const flagGrabsTG = parseInt(player.stats.flagGrabsTG[0]);
|
||||||
|
const flagCapsTG = parseInt(player.stats.flagCapsTG[0]) * 100;
|
||||||
|
const totalFlagScore = flagGrabsTG + flagCapsTG;
|
||||||
|
|
||||||
|
if (player.stats.dtTeamGame[0] === '1') {
|
||||||
|
// Storm
|
||||||
|
game.teams.storm.score += totalFlagScore;
|
||||||
|
game.teams.storm.players.push(p);
|
||||||
|
} else if (player.stats.dtTeamGame[0] === '2') {
|
||||||
|
// Inferno
|
||||||
|
game.teams.inferno.score += totalFlagScore;
|
||||||
|
game.teams.inferno.players.push(p);
|
||||||
|
} else {
|
||||||
|
// OBS
|
||||||
|
game.teams.obs.score += totalFlagScore;
|
||||||
|
game.teams.obs.players.push(p);
|
||||||
|
}
|
||||||
|
console.log(player.stats.dtTeamGame);
|
||||||
|
}
|
||||||
|
|
||||||
|
//const teamZero: any = game; //game.find(({ stats }) => stats.dtTeamGame[0] === '3');
|
||||||
|
|
||||||
|
// const teamOne: any = game.find(({ stats }) => stats.dtTeamGame[0] === '1');
|
||||||
|
// const teamTwo: any = game.find(({ stats }) => stats.dtTeamGame[0] === '2');
|
||||||
|
|
||||||
return game;
|
return game;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue