Fix player fraction resolving for FF and others (CC-55)
parent
22cf01727b
commit
e1804a9918
|
@ -107,21 +107,30 @@ 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) {
|
||||||
|
kill.shooter = shooter.name;
|
||||||
|
kill.fraction = shooter.fraction;
|
||||||
|
if (target) {
|
||||||
|
kill.friendlyFire = (target.fraction === shooter.fraction);
|
||||||
|
}
|
||||||
if (shooter.magazine) {
|
if (shooter.magazine) {
|
||||||
kill.magazine = shooter.magazine;
|
kill.magazine = shooter.magazine;
|
||||||
}
|
}
|
||||||
if (shooter.vehicle) {
|
if (shooter.vehicle) {
|
||||||
kill.shooterVehicle = shooter.vehicle;
|
kill.shooterVehicle = shooter.vehicle;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
kill.fraction = 'NONE';
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
} else if (line.includes('(Budget)')) {
|
} else if (line.includes('(Budget)')) {
|
||||||
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue