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