From 9767e1bf250acd412f39573b5c0873d515f24532 Mon Sep 17 00:00:00 2001 From: HardiReady Date: Sat, 14 Apr 2018 17:46:01 +0200 Subject: [PATCH] Fix player parsing for vehicle classes --- api/tools/log-parse-tool.js | 27 +++++++++++++++---- static/src/app/models/model-interfaces.ts | 4 ++- .../highscore/highscore.component.ts | 2 +- .../scoreboard/scoreboard.component.html | 12 +++++---- .../scoreboard/scoreboard.component.ts | 7 +++-- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/api/tools/log-parse-tool.js b/api/tools/log-parse-tool.js index 4d787af..b65e3db 100644 --- a/api/tools/log-parse-tool.js +++ b/api/tools/log-parse-tool.js @@ -199,14 +199,31 @@ const parseWarLog = (lineArray, war) => { for (let i = 0; i < stats.players.length; i++) { const playerName = stats.players[i].name; stats.players[i]['respawn'] = stats.respawn.filter((res) => res.player === playerName).length; + stats.players[i]['kill'] = stats.kills.filter((kill) => kill.shooter === playerName && !kill.friendlyFire).length; - stats.players[i]['vehicle'] = stats.vehicles.filter( - (vehicle) => vehicle.shooter === playerName && VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; + + //TODO: use vehicle class description from enum + stats.players[i]['vehicleLight'] = stats.vehicles.filter( + (vehicle) => vehicle.shooter === playerName && vehicle.vehicleClass === 'LIGHT' && + VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; + + stats.players[i]['vehicleHeavy'] = stats.vehicles.filter( + (vehicle) => vehicle.shooter === playerName && vehicle.vehicleClass === 'HEAVY' && + VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; + + stats.players[i]['vehicleAir'] = stats.vehicles.filter( + (vehicle) => vehicle.shooter === playerName && vehicle.vehicleClass === 'AIR' && + VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; + stats.players[i]['friendlyFire'] = stats.kills.filter( (kill) => kill.shooter === playerName && kill.friendlyFire).length; + stats.players[i]['death'] = stats.kills.filter((kill) => kill.target === playerName).length; + stats.players[i]['revive'] = stats.revive.filter((rev) => rev.medic === playerName && !rev.stabilized).length; + stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length; + stats.players[i]['sort'] = stats.players[i]['kill'] + stats.players[i]['revive'] + stats.players[i]['flagTouch'] - stats.players[i]['friendlyFire'] - stats.players[i]['death'] - stats.players[i]['respawn']; } @@ -263,12 +280,12 @@ const getVehicleAndFractionFromString = (nameClassFractionString) => { const vehicleFraction = nameArray[nameArray.length - 1]; nameArray.pop(); - const veheicleClassString = nameArray[nameArray.length - 1].replace('(', '').replace(')', ''); + const vehicleClassString = nameArray[nameArray.length - 1].replace('(', '').replace(')', ''); nameArray.pop(); const vehicleName = nameArray.join(WHITESPACE); // skip logging here - this is some basic equipment identifier (i.e. parachute) - if (vehicleFraction === 'OPF_F' || vehicleFraction === 'BLU_F' || veheicleClassString === VehicleClasses.UNKNOWN) { + if (vehicleFraction === 'OPF_F' || vehicleFraction === 'BLU_F' || vehicleClassString === VehicleClasses.UNKNOWN) { return; } @@ -276,7 +293,7 @@ const getVehicleAndFractionFromString = (nameClassFractionString) => { let vehicleClass; for (const key in VehicleClasses) { - if (VehicleClasses.hasOwnProperty(key) && VehicleClasses[key] === veheicleClassString) { + if (VehicleClasses.hasOwnProperty(key) && VehicleClasses[key] === vehicleClassString) { vehicleClass = key; } } diff --git a/static/src/app/models/model-interfaces.ts b/static/src/app/models/model-interfaces.ts index 20cb379..bc7a72b 100644 --- a/static/src/app/models/model-interfaces.ts +++ b/static/src/app/models/model-interfaces.ts @@ -24,7 +24,9 @@ export interface Player { name?: string; warId?: War; kill?: number; - vehicle?: number; + vehicleLight?: number; + vehicleHeavy?: number; + vehicleAir?: number; death?: number; friendlyFire?: number; revive?: number; diff --git a/static/src/app/statistic/highscore/highscore.component.ts b/static/src/app/statistic/highscore/highscore.component.ts index 94bd477..2cab191 100644 --- a/static/src/app/statistic/highscore/highscore.component.ts +++ b/static/src/app/statistic/highscore/highscore.component.ts @@ -87,7 +87,7 @@ export class StatisticHighScoreComponent implements OnInit { this.players = { kill: this.filterPlayerAttribute('kill'), friendlyFire: this.filterPlayerAttribute('friendlyFire'), - vehicle: this.filterPlayerAttribute('vehicle'), + vehicleLight: this.filterPlayerAttribute('vehicleLight'), death: this.filterPlayerAttribute('death'), respawn: this.filterPlayerAttribute('respawn'), revive: this.filterPlayerAttribute('revive'), diff --git a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.html b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.html index f7ddd5a..57356d1 100644 --- a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.html +++ b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.html @@ -25,11 +25,13 @@ - - - - - + + + + + + + diff --git a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts index fd4455c..25e35ae 100644 --- a/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts +++ b/static/src/app/statistic/war-detail/scoreboard/scoreboard.component.ts @@ -19,7 +19,8 @@ export class ScoreboardComponent implements OnChanges { @Output() playerTabSwitch = new EventEmitter(); - tableHead = ['Spieler', 'Fraktion', 'Kills', 'FriendlyFire', 'Fahrzeug', 'Revive', 'Eroberung', 'Tod', 'Respawn']; + tableHead = ['Spieler', 'Fraktion', 'Kills', 'FriendlyFire', 'Fzg(L)', 'Fzg(S)', 'Fzg(A)', + 'Revive', 'Eroberung', 'Tod', 'Respawn']; isSteamUUID = PlayerUtils.isSteamUUID; @@ -82,7 +83,9 @@ export class ScoreboardComponent implements OnChanges { csvOut += player.fraction + ','; csvOut += player.kill + ','; csvOut += player.friendlyFire + ','; - csvOut += player.vehicle + ','; + csvOut += player.vehicleLight + ','; + csvOut += player.vehicleHeavy + ','; + csvOut += player.vehicleAir + ','; csvOut += player.revive + ','; csvOut += player.flagTouch + ','; csvOut += player.death + ',';