mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-01-19 17:34:43 +00:00
Use new teamScoreGame key to display team v team score. Fall back to old tally method if its not available
This commit is contained in:
parent
c1fcb61731
commit
a14fec7355
|
|
@ -4,6 +4,7 @@
|
|||
function formatPlayerStats(statObj: any) {
|
||||
return {
|
||||
...statObj.stats,
|
||||
teamScoreGame: Number(statObj.stats.teamScoreGame),
|
||||
masTG: Number(statObj.stats.masTG),
|
||||
cgMATG: Number(statObj.stats.cgMATG),
|
||||
kdrAvg: Number(statObj.stats.kdrAvg),
|
||||
|
|
|
|||
|
|
@ -13,14 +13,16 @@ export class GameService {
|
|||
constructor(
|
||||
private readonly connection: Connection,
|
||||
private readonly configService: ConfigService,
|
||||
@InjectRepository(Games) private readonly gamesRepository: Repository<Games>,
|
||||
@InjectRepository(GameDetail) private readonly gameRepository: Repository<GameDetail>
|
||||
@InjectRepository(Games)
|
||||
private readonly gamesRepository: Repository<Games>,
|
||||
@InjectRepository(GameDetail)
|
||||
private readonly gameRepository: Repository<GameDetail>,
|
||||
) {}
|
||||
|
||||
async findOne(gameId: string) {
|
||||
const query = await this.gameRepository.find({
|
||||
relations: [ 'game', 'playerGuid' ],
|
||||
where: [ { game: { gameId: gameId } } ]
|
||||
relations: ['game', 'playerGuid'],
|
||||
where: [{ game: { gameId: gameId } }],
|
||||
});
|
||||
|
||||
if (!query.length) {
|
||||
|
|
@ -28,7 +30,7 @@ export class GameService {
|
|||
}
|
||||
|
||||
const game: any = {
|
||||
...query[0].game
|
||||
...query[0].game,
|
||||
};
|
||||
|
||||
// Need to set return based off gameType
|
||||
|
|
@ -42,7 +44,7 @@ export class GameService {
|
|||
const p = {
|
||||
playerGuid: player.playerGuid.playerGuid,
|
||||
playerName,
|
||||
stats
|
||||
stats,
|
||||
};
|
||||
|
||||
game.players.push(p);
|
||||
|
|
@ -55,7 +57,7 @@ export class GameService {
|
|||
game['teams'] = {
|
||||
obs: { score: 0, players: [] },
|
||||
storm: { score: 0, players: [] },
|
||||
inferno: { score: 0, players: [] }
|
||||
inferno: { score: 0, players: [] },
|
||||
};
|
||||
|
||||
const teamZero = [],
|
||||
|
|
@ -69,9 +71,11 @@ export class GameService {
|
|||
const p = {
|
||||
playerGuid: player.playerGuid.playerGuid,
|
||||
playerName,
|
||||
stats
|
||||
stats,
|
||||
};
|
||||
|
||||
if (isNaN(player.stats.teamScoreGame)) {
|
||||
// legacy calculations for game totals (not using the new teamScoreGame attribute)
|
||||
const flagGrabsTG = parseInt(player.stats.flagGrabsTG[0]);
|
||||
const flagCapsTG = parseInt(player.stats.flagCapsTG[0]) * 100;
|
||||
const totalFlagScore = flagGrabsTG + flagCapsTG;
|
||||
|
|
@ -89,19 +93,41 @@ export class GameService {
|
|||
game.teams.obs.score += totalFlagScore;
|
||||
teamZero.push(p);
|
||||
}
|
||||
} else {
|
||||
// Use new player.stats.teamScoreGame key
|
||||
if (player.stats.dtTeamGame[0] === '1') {
|
||||
// Storm
|
||||
game.teams.storm.score = Number(player.stats.teamScoreGame);
|
||||
teamOne.push(p);
|
||||
} else if (player.stats.dtTeamGame[0] === '2') {
|
||||
// Inferno
|
||||
game.teams.inferno.score = Number(player.stats.teamScoreGame);
|
||||
teamTwo.push(p);
|
||||
} else {
|
||||
// OBS
|
||||
game.teams.obs.score = Number(player.stats.teamScoreGame);
|
||||
teamZero.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
game['teams']['obs']['players'] = teamZero.sort((a, b) => b.stats.scoreTG - a.stats.scoreTG);
|
||||
game['teams']['storm']['players'] = teamOne.sort((a, b) => b.stats.scoreTG - a.stats.scoreTG);
|
||||
game['teams']['inferno']['players'] = teamTwo.sort((a, b) => b.stats.scoreTG - a.stats.scoreTG);
|
||||
game['teams']['obs']['players'] = teamZero.sort(
|
||||
(a, b) => b.stats.scoreTG - a.stats.scoreTG,
|
||||
);
|
||||
game['teams']['storm']['players'] = teamOne.sort(
|
||||
(a, b) => b.stats.scoreTG - a.stats.scoreTG,
|
||||
);
|
||||
game['teams']['inferno']['players'] = teamTwo.sort(
|
||||
(a, b) => b.stats.scoreTG - a.stats.scoreTG,
|
||||
);
|
||||
|
||||
return game;
|
||||
}
|
||||
|
||||
async findOneAbvSummary(gameId: string) {
|
||||
const query = await this.gameRepository.find({
|
||||
relations: [ 'game', 'playerGuid' ],
|
||||
where: [ { game: { gameId: gameId } } ]
|
||||
relations: ['game', 'playerGuid'],
|
||||
where: [{ game: { gameId: gameId } }],
|
||||
});
|
||||
|
||||
if (!query.length) {
|
||||
|
|
@ -109,7 +135,7 @@ export class GameService {
|
|||
}
|
||||
|
||||
const game: any = {
|
||||
...query[0].game
|
||||
...query[0].game,
|
||||
};
|
||||
|
||||
// Need to set return based off gameType
|
||||
|
|
@ -130,9 +156,11 @@ export class GameService {
|
|||
game['teams'] = {
|
||||
obs: { score: 0, playerCount: 0 },
|
||||
storm: { score: 0, playerCount: 0 },
|
||||
inferno: { score: 0, playerCount: 0 }
|
||||
inferno: { score: 0, playerCount: 0 },
|
||||
};
|
||||
|
||||
console.log(query);
|
||||
|
||||
for (const player of query) {
|
||||
const flagGrabsTG = parseInt(player.stats.flagGrabsTG[0]);
|
||||
const flagCapsTG = parseInt(player.stats.flagCapsTG[0]) * 100;
|
||||
|
|
@ -152,7 +180,8 @@ export class GameService {
|
|||
game.teams.obs.playerCount += 1;
|
||||
}
|
||||
}
|
||||
game['totalScore'] = game.teams.storm.score + game.teams.inferno.score + game.teams.obs.score;
|
||||
game['totalScore'] =
|
||||
game.teams.storm.score + game.teams.inferno.score + game.teams.obs.score;
|
||||
|
||||
return game;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ services:
|
|||
replicas: 1
|
||||
|
||||
api:
|
||||
image: "amineo/t2-stats-api:v0.0.13"
|
||||
image: "amineo/t2-stats-api:v0.0.14"
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./build/api/Dockerfile
|
||||
|
|
|
|||
Loading…
Reference in a new issue