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,21 +107,30 @@ 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) {
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 (target) {
kill.target = target.name;
if (target.vehicle) {
kill.targetVehicle = target.vehicle;
}
}
stats.kills.push(kill);
}
} else if (line.includes('(Budget)')) {
@ -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