mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-07-13 15:24:35 +00:00
Calculate stat totals
This commit is contained in:
parent
229ce10466
commit
cdbcbe19e3
1 changed files with 27 additions and 1 deletions
|
|
@ -39,9 +39,35 @@ class PlayerController {
|
||||||
'stats')
|
'stats')
|
||||||
.where({ player_guid: request.params.player_guid })
|
.where({ player_guid: request.params.player_guid })
|
||||||
|
|
||||||
|
|
||||||
|
let playerStatTotals = {},
|
||||||
|
statKeys = Object.keys(playerStatData[0].stats)
|
||||||
|
|
||||||
|
for(let i = 0 ; i < statKeys.length; i++) {
|
||||||
|
if(statKeys[i] === "map" ||
|
||||||
|
statKeys[i] === "dateStamp" ||
|
||||||
|
statKeys[i] === "timeDayMonth" ){continue;}
|
||||||
|
playerStatTotals[statKeys[i]] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
playerStatData.map(statLine => {
|
||||||
|
for (let [key, value] of Object.entries(statLine.stats)) {
|
||||||
|
// console.log(`${key}: ${value}`);
|
||||||
|
if(playerStatTotals.hasOwnProperty(key) === true){
|
||||||
|
playerStatTotals[key] = playerStatTotals[key] + Number(value);
|
||||||
|
}else{
|
||||||
|
playerStatTotals[key] = Number(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(playerStatTotals);
|
||||||
|
|
||||||
let playerData = {
|
let playerData = {
|
||||||
player: playerInfo[0],
|
player: playerInfo[0],
|
||||||
stats: playerStatData
|
stats: playerStatData,
|
||||||
|
totals: playerStatTotals
|
||||||
}
|
}
|
||||||
|
|
||||||
const pageTitle = playerData.player.player_name
|
const pageTitle = playerData.player.player_name
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue