parse vehicle class from log
parent
910df3d267
commit
b927d48b86
|
@ -4,6 +4,13 @@ const playerArrayContains = require('./util').playerArrayContains;
|
|||
|
||||
const WHITESPACE = ' ';
|
||||
|
||||
const VehicleClasses = Object.freeze({
|
||||
LIGHT: "Leicht",
|
||||
HEAVY: "Leicht",
|
||||
AIR: "Flug",
|
||||
UNKNOWN: "Unbekannt"
|
||||
});
|
||||
|
||||
const parseWarLog = (lineArray, war) => {
|
||||
const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
|
||||
|
||||
|
@ -21,7 +28,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
players: [],
|
||||
};
|
||||
|
||||
const vehicleBlacklist = [
|
||||
const VEHICLE_BLACKLIST = [
|
||||
'Prowler (Unbewaffnet)', 'Prowler (Bewaffnet)', 'Hunter',
|
||||
'HEMTT Transporter', 'HEMTT Transporter (abgedeckt)', 'HEMTT SanitÀtsfahrzeug',
|
||||
'Remote Designator [NATO]', 'UGV Stomper',
|
||||
|
@ -193,7 +200,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
stats.players[i]['respawn'] = stats.respawn.filter((res) => res.player === playerName).length;
|
||||
stats.players[i]['kill'] = stats.kills.filter((kill) => kill.shooter === playerName && !kill.friendlyFire).length;
|
||||
stats.players[i]['vehicle'] = stats.vehicles.filter(
|
||||
(vehicle) => vehicle.shooter === playerName && vehicleBlacklist.indexOf(vehicle.target) < 0).length;
|
||||
(vehicle) => vehicle.shooter === playerName && VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length;
|
||||
stats.players[i]['friendlyFire'] = stats.kills.filter(
|
||||
(kill) => kill.shooter === playerName && kill.friendlyFire).length;
|
||||
stats.players[i]['death'] = stats.kills.filter((kill) => kill.target === playerName).length;
|
||||
|
@ -250,19 +257,23 @@ const getPlayerAndFractionFromString = (nameAndFractionString) => {
|
|||
}
|
||||
};
|
||||
|
||||
const getVehicleAndFractionFromString = (nameAndFractionString) => {
|
||||
const nameArray = nameAndFractionString.trim().split(WHITESPACE);
|
||||
const fractionPart = nameArray[nameArray.length - 1];
|
||||
const getVehicleAndFractionFromString = (nameClassFractionString) => {
|
||||
const nameArray = nameClassFractionString.trim().split(WHITESPACE);
|
||||
|
||||
// escape it is some parachute fraction identifier
|
||||
if (fractionPart === 'OPF_F' || fractionPart === 'BLU_F') {
|
||||
const vehicleFraction = nameArray[nameArray.length - 1];
|
||||
nameArray.pop();
|
||||
const vehicleClass = nameArray[nameArray.length - 1].replace('(', '').replace(')', '');
|
||||
nameArray.pop();
|
||||
const vehicleName = nameArray.join(WHITESPACE);
|
||||
|
||||
// nno counting here - is some basic fraction equipment identifier (i.e. parachute)
|
||||
if (vehicleFraction === 'OPF_F' || vehicleFraction === 'BLU_F' || vehicleClass === VehicleClasses.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fraction = fractionPart === '(OPT_NATO)' || fractionPart === '(OPT_NATO_T)' ? 'BLUFOR' : 'OPFOR';
|
||||
const name = nameAndFractionString.substring(0, nameAndFractionString.indexOf(fractionPart) - 1);
|
||||
const fraction = vehicleFraction === '(OPT_NATO)' || vehicleFraction === '(OPT_NATO_T)' ? 'BLUFOR' : 'OPFOR';
|
||||
|
||||
return {name: name, fraction: fraction};
|
||||
return {name: vehicleName, fraction: fraction, class: vehicleClass};
|
||||
};
|
||||
|
||||
const transformMoneyString = (budgetString) => {
|
||||
|
|
Loading…
Reference in New Issue