Add vehicle kills to fraction stats

pull/29/head
HardiReady 2018-03-03 13:17:36 +01:00
parent 57f093f4dc
commit 840695bf0e
3 changed files with 37 additions and 2 deletions

View File

@ -13,6 +13,7 @@ const LogBudgetModel = require('../models/logs/budget');
const LogRespawnModel = require('../models/logs/respawn');
const LogReviveModel = require('../models/logs/revive');
const LogKillModel = require('../models/logs/kill');
const LogVehicleModel = require('../models/logs/vehicle');
const LogTransportModel = require('../models/logs/transport');
const LogFlagModel = require('../models/logs/flag');
const LogPointsModel = require('../models/logs/points');
@ -43,6 +44,7 @@ logsRouter.route('/:warId')
const respawnObjects = LogRespawnModel.find(filter, {}, sort);
const reviveObjects = LogReviveModel.find(filter, {}, sort);
const killObjects = LogKillModel.find(filter, {}, sort);
const vehicleObjects = LogVehicleModel.find(filter, {}, sort);
const transportObjects = LogTransportModel.find(filter, {}, sort);
const flagObjects = LogFlagModel.find(filter, {}, sort);
const resources = {
@ -51,6 +53,7 @@ logsRouter.route('/:warId')
respawn: respawnObjects.exec.bind(respawnObjects),
revive: reviveObjects.exec.bind(reviveObjects),
kill: killObjects.exec.bind(killObjects),
vehicle: killObjects.exec.bind(vehicleObjects),
transport: transportObjects.exec.bind(transportObjects),
flag: flagObjects.exec.bind(flagObjects)
};

View File

@ -28,6 +28,8 @@
btnRadio="{{labelKill}}">{{labelKill}}</label>
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel"
btnRadio="{{labelFriendlyFire}}">{{labelFriendlyFire}}</label>
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel"
btnRadio="{{labelVehicle}}">{{labelVehicle}}</label>
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel"
btnRadio="{{labelRevive}}">{{labelRevive}}</label>
<label class="btn btn-default btn-dark" [(ngModel)]="chartSelectModel"

View File

@ -34,6 +34,7 @@ export class FractionStatsComponent {
tmpBudgetData;
tmpKillData;
tmpFrienlyFireData;
tmpVehicleData;
tmpTransportData;
tmpReviveData;
tmpStabilizeData;
@ -47,6 +48,7 @@ export class FractionStatsComponent {
labelBudget = 'Budget';
labelKill = 'Kills';
labelFriendlyFire = 'FriendlyFire';
labelVehicle = 'Fahrzeug-Kills';
labelTransport = 'Lufttransport';
labelRevive = 'Revive';
labelStabilize = 'Stabilisiert';
@ -111,6 +113,10 @@ export class FractionStatsComponent {
this.initKillData();
this.lineChartData = this.tmpFrienlyFireData;
break;
case this.labelVehicle:
this.initVehicleData();
this.lineChartData = this.tmpVehicleData;
break;
case this.labelRevive:
this.initRevive();
this.lineChartData = this.tmpReviveData;
@ -250,6 +256,30 @@ export class FractionStatsComponent {
this.initialized.revive = true;
}
initVehicleData() {
if (this.initialized.vehicle) {
return;
}
let vehicleKillCountBlufor = 0, vehicleKillCountOpfor = 0;
for (const {transportEntry: vehicleEntry, index} of this.logData.vehicle.map((transportEntry, index) => ({
transportEntry,
index
}))) {
const vehicleEntryDate = new Date(vehicleEntry.time);
if (vehicleEntry.fraction === 'BLUFOR') {
vehicleKillCountBlufor++;
} else {
vehicleKillCountOpfor++;
}
if (this.isTwoMinutesAhead(vehicleEntryDate, this.tmpVehicleData) || index === this.logData.vehicle.length - 1) {
this.tmpVehicleData[0].series.push(ChartUtils.getSeriesEntry(vehicleEntryDate, vehicleKillCountBlufor));
this.tmpVehicleData[1].series.push(ChartUtils.getSeriesEntry(vehicleEntryDate, vehicleKillCountOpfor));
}
}
this.addFinalTimeData(this.tmpVehicleData);
this.initialized.vehicle = true;
}
initTransportData() {
if (this.initialized.transport) {
return;
@ -272,7 +302,6 @@ export class FractionStatsComponent {
}
this.addFinalTimeData(this.tmpTransportData);
this.initialized.transport = true;
}
initFlagHoldData() {
@ -308,12 +337,13 @@ export class FractionStatsComponent {
this.tmpBudgetData = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
this.tmpKillData = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
this.tmpFrienlyFireData = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
this.tmpVehicleData = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
this.tmpTransportData = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
this.tmpReviveData = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
this.tmpStabilizeData = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
this.tmpFlagCaptureData = ChartUtils.getMultiDataArray(Fraction.BLUFOR, Fraction.OPFOR);
[this.tmpKillData, this.tmpFrienlyFireData, this.tmpReviveData, this.tmpStabilizeData, this.tmpTransportData].forEach(tmp => {
[this.tmpKillData, this.tmpFrienlyFireData, this.tmpVehicleData, this.tmpReviveData, this.tmpStabilizeData, this.tmpTransportData].forEach(tmp => {
[0, 1].forEach(index => {
tmp[index].series.push(ChartUtils.getSeriesEntry(this.startDateObj, 0));
})