2017-10-01 20:24:35 +02:00
|
|
|
import {Component} from "@angular/core";
|
|
|
|
import {ActivatedRoute} from "@angular/router";
|
|
|
|
import {CampaignPlayer} from "../../models/model-interfaces";
|
|
|
|
import {PlayerService} from "../../services/player-service/player.service";
|
2017-10-02 14:41:17 +02:00
|
|
|
import {ChartUtils} from "../../utils/chart-utils";
|
2017-10-01 20:24:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'campaign-player-detail',
|
|
|
|
templateUrl: './campaign-player-detail.component.html',
|
|
|
|
styleUrls: ['./campaign-player-detail.component.css']
|
|
|
|
})
|
|
|
|
export class CampaignPlayerDetailComponent {
|
|
|
|
|
2017-10-02 14:41:17 +02:00
|
|
|
campaignPlayer: CampaignPlayer = {campaign: {}, players: []};
|
2017-10-01 20:24:35 +02:00
|
|
|
|
2017-10-02 14:41:17 +02:00
|
|
|
killData: any[] = [];
|
|
|
|
|
|
|
|
colorScheme = {
|
|
|
|
domain: ['#00ce12']
|
|
|
|
};
|
|
|
|
showRefLines = true;
|
|
|
|
showRefLabels = true;
|
|
|
|
refLines = [];
|
|
|
|
gradient = false;
|
|
|
|
xAxis = true;
|
|
|
|
yAxis = true;
|
|
|
|
legend = false;
|
|
|
|
legendTitle = '';
|
|
|
|
showXAxisLabel = true;
|
|
|
|
showYAxisLabel = true;
|
|
|
|
autoscale = false;
|
|
|
|
timeline = false;
|
|
|
|
roundDomains = true;
|
2017-10-01 20:24:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute,
|
|
|
|
private playerService: PlayerService) {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.route.params
|
|
|
|
.map(params => [params['id'], params['playerName']])
|
|
|
|
.flatMap(id => this.playerService.getCampaignPlayer(id[0], id[1]))
|
|
|
|
.subscribe(campaignPlayer => {
|
|
|
|
this.campaignPlayer = campaignPlayer;
|
2017-10-02 14:41:17 +02:00
|
|
|
this.assignKillData();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private assignKillData() {
|
|
|
|
let killObj = {
|
|
|
|
"name": "Kills",
|
|
|
|
"series": []
|
|
|
|
};
|
|
|
|
let total = 0;
|
|
|
|
for (let i = 0; i < this.campaignPlayer.players.length; i++) {
|
|
|
|
const warDateString = ChartUtils.getShortDateString(this.campaignPlayer.players[i].warId.date);
|
|
|
|
const warKills = this.campaignPlayer.players[i].kill;
|
|
|
|
killObj.series.push({
|
|
|
|
name: warDateString,
|
|
|
|
value: warKills
|
2017-10-01 20:24:35 +02:00
|
|
|
});
|
2017-10-02 14:41:17 +02:00
|
|
|
total += warKills;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.killData = [killObj];
|
|
|
|
Object.assign(this, this.killData);
|
|
|
|
this.refLines.push({value: total / this.campaignPlayer.players.length, name: 'Durchschnitt'});
|
|
|
|
|
2017-10-01 20:24:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|