Fix player fraction resolving for FF and others (CC-55)

pull/45/head
HardiReady 2018-09-30 14:43:01 +02:00
parent 22cf01727b
commit e1804a9918
1 changed files with 27 additions and 15 deletions

View File

@ -107,20 +107,29 @@ const parseWarLog = (lineArray, war) => {
const target = getPlayerInfoFromString(targetString);
const kill = {
war: war._id,
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
shooter: shooter ? shooter.name : null,
target: target ? target.name : null,
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
fraction: shooter ? shooter.fraction : 'NONE',
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5])
};
if (shooter.magazine) {
kill.magazine = shooter.magazine;
if (shooter) {
kill.shooter = shooter.name;
kill.fraction = shooter.fraction;
if (target) {
kill.friendlyFire = (target.fraction === shooter.fraction);
}
if (shooter.magazine) {
kill.magazine = shooter.magazine;
}
if (shooter.vehicle) {
kill.shooterVehicle = shooter.vehicle;
}
} else {
kill.fraction = 'NONE';
}
if (shooter.vehicle) {
kill.shooterVehicle = shooter.vehicle;
}
if (target.vehicle) {
kill.targetVehicle = target.vehicle;
if (target) {
kill.target = target.name;
if (target.vehicle) {
kill.targetVehicle = target.vehicle;
}
}
stats.kills.push(kill);
}
@ -312,12 +321,15 @@ const getPlayerInfoFromString = (inputString) => {
let name;
if (playerNameRegexMatch && playerNameRegexMatch.length >= 2) {
name = playerNameRegexMatch[2].trim();
// do not return player for 'Error: No unit'
if (!name && name === 'Error: No unit') {
// do not return player for 'unbekannt' or 'Error: No unit'
if (!name || name === 'unbekannt' || name === 'Error: No unit' || name === 'Selbstverschulden.') {
return;
}
resPlayer.name = name;
} else {
return;
}
// ADDITIONAL PLAYER NAMES
let additionalPlayerMatch;
while ((additionalPlayerMatch = playerNameRegex.exec(inputString)) !== null) {
@ -341,7 +353,7 @@ const getPlayerInfoFromString = (inputString) => {
}
if (side && side !== 'ENEMY') {
resPlayer.fraction = side === 'WEST' ? 'BLUFOR' : 'OPFOR';
resPlayer.fraction = (side === 'WEST') ? 'BLUFOR' : 'OPFOR';
}
// MAGAZINE