Adjust player stat attribute order; improve code for player campaign stats init
parent
d6703f715d
commit
96afbefbf2
|
@ -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({
|
||||
|
@ -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,27 +62,20 @@ 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 = [];
|
||||
|
|
|
@ -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'}
|
||||
];
|
||||
|
||||
|
|
Loading…
Reference in New Issue