diff --git a/static/src/app/statistic/campaign/campaign-player-detail/campaign-player-detail.component.ts b/static/src/app/statistic/campaign/campaign-player-detail/campaign-player-detail.component.ts index c0f6953..9ac834a 100644 --- a/static/src/app/statistic/campaign/campaign-player-detail/campaign-player-detail.component.ts +++ b/static/src/app/statistic/campaign/campaign-player-detail/campaign-player-detail.component.ts @@ -2,6 +2,7 @@ import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; import {CampaignPlayer} from '../../../models/model-interfaces'; import {PlayerService} from '../../../services/logs/player.service'; import {ChartUtils} from '../../../utils/chart-utils'; +import {PlayerUtils} from '../../../utils/player-utils'; @Component({ @@ -18,7 +19,7 @@ export class CampaignPlayerDetailComponent implements OnInit { @Output() switchTab = new EventEmitter(); - campaignPlayer: CampaignPlayer = { campaign: {}, players: [] }; + campaignPlayer: CampaignPlayer = {campaign: {}, players: []}; graphData: any[] = []; sumData: any[] = []; @@ -51,6 +52,8 @@ export class CampaignPlayerDetailComponent implements OnInit { respawnDeathRatio = 0; maxRespawnDeathRatio = 1; + playerAttributeNameMap = PlayerUtils.attributeDisplayNames.slice(2, PlayerUtils.attributeDisplayNames.length); + constructor(private playerService: PlayerService) { } @@ -59,32 +62,25 @@ export class CampaignPlayerDetailComponent implements OnInit { .subscribe(campaignPlayer => { this.campaignPlayer = campaignPlayer; - this.graphData = [ - { key: 'kill', label: 'Abschüsse', }, - { key: 'friendlyFire', label: 'Friendly Fire', }, - { key: 'death', label: 'Tode', }, - { key: 'respawn', label: 'Respawn', }, - { key: 'revive', label: 'Revive', }, - { key: 'flagTouch', label: 'Eroberungen', }, - { key: 'vehicleLight', label: 'Fahrzeug (Leicht)', }, - { key: 'vehicleHeavy', label: 'Fahrzeug (Schwer)', }, - { key: 'vehicleAir', label: 'Fahrzeug (Luft)', }, - ]; + for (let i = 0; i < this.playerAttributeNameMap.length; i++) { + const attr = this.playerAttributeNameMap[i]; + this.graphData.push({key: attr.prop, label: attr.head}); + } this.initDataArray(); - const totalDeathDiv = this.graphData[2].total === 0 ? 1 : this.graphData[2].total; + const totalDeathDiv = this.graphData[7].total === 0 ? 1 : this.graphData[7].total; this.kdRatio = parseFloat((this.graphData[0].total / totalDeathDiv).toFixed(2)); if (this.kdRatio > 1) { this.maxKd = this.kdRatio * 1.7; } - this.respawnDeathRatio = parseFloat((this.graphData[3].total / totalDeathDiv).toFixed(2)); + this.respawnDeathRatio = parseFloat((this.graphData[8].total / totalDeathDiv).toFixed(2)); // we can not directly push to target array, since only full reference changes trigger the refresh of data const tmpSumData = []; this.graphData.forEach(dataSet => { - tmpSumData.push({ name: dataSet.label, value: dataSet.total }); + tmpSumData.push({name: dataSet.label, value: dataSet.total}); }); this.sumData = tmpSumData; }); @@ -109,7 +105,7 @@ export class CampaignPlayerDetailComponent implements OnInit { } dataSet.data = [killObj]; - dataSet.refLine = [{ value: total / playerLength, name: this.avgLabel }]; + dataSet.refLine = [{value: total / playerLength, name: this.avgLabel}]; dataSet.total = total; }); } diff --git a/static/src/app/utils/player-utils.ts b/static/src/app/utils/player-utils.ts index 7f530d7..b2957ab 100644 --- a/static/src/app/utils/player-utils.ts +++ b/static/src/app/utils/player-utils.ts @@ -1,10 +1,16 @@ export class PlayerUtils { public static readonly attributeDisplayNames = [ - {prop: 'name', head: 'Spieler'}, {prop: 'fraction', head: 'Fraktion'}, {prop: 'kill', head: 'Abschüsse'}, - {prop: 'friendlyFire', head: 'Friendly Fire'}, {prop: 'vehicleLight', head: 'Fahrzeug (leicht)'}, - {prop: 'vehicleHeavy', head: 'Fahrzeug (schwer)'}, {prop: 'vehicleAir', head: 'Fahrzeug (Luft)'}, - {prop: 'revive', head: 'Revive'}, {prop: 'flagTouch', head: 'Eroberungen'}, {prop: 'death', head: 'Tode'}, + {prop: 'name', head: 'Spieler'}, + {prop: 'fraction', head: 'Fraktion'}, + {prop: 'kill', head: 'Abschüsse'}, + {prop: 'friendlyFire', head: 'Friendly Fire'}, + {prop: 'revive', head: 'Revive'}, + {prop: 'flagTouch', head: 'Eroberungen'}, + {prop: 'vehicleLight', head: 'Fahrzeug (leicht)'}, + {prop: 'vehicleHeavy', head: 'Fahrzeug (schwer)'}, + {prop: 'vehicleAir', head: 'Fahrzeug (Luft)'}, + {prop: 'death', head: 'Tode'}, {prop: 'respawn', head: 'Respawn'} ];