Save additional shopoters for vehicle kill

pull/36/head
HardiReady 2018-06-09 19:31:22 +02:00
parent d10fc8e49a
commit fc5eaf868a
2 changed files with 13 additions and 3 deletions

View File

@ -16,6 +16,9 @@ const LogVehicleKillSchema = new Schema({
shooter: {
type: String,
},
additionalShooter: {
type: [String],
},
target: {
type: String,
required: true,

View File

@ -80,14 +80,21 @@ const parseWarLog = (lineArray, war) => {
const targetString = line.substring(line.lastIndexOf(' --- Fahrzeug: ') + 15, line.lastIndexOf(' von:'));
const target = getVehicleAndFractionFromString(targetString);
if (target && shooter && target.fraction !== shooter.fraction) {
stats.vehicles.push({
const vehicleKill = {
war: war._id,
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
shooter: shooter ? shooter.name : null,
target: target ? target.name : null,
fraction: shooter ? shooter.fraction : 'NONE',
vehicleClass: target.vehicleClass,
});
};
if (shooter && shooter.name instanceof Array) {
vehicleKill.shooter = shooter.name[0];
vehicleKill.additionalShooter = shooter.name.slice(1, shooter.name.length);
} else {
vehicleKill.shooter = shooter ? shooter.name : null
}
console.log(vehicleKill)
stats.vehicles.push(vehicleKill);
}
} else {
const targetString = line.substring(line.lastIndexOf(' --- Einheit: ') + 14, line.lastIndexOf(' von:'));