|
|
@ -11,6 +11,18 @@ const VehicleClasses = Object.freeze({
|
|
|
|
UNKNOWN: 'Unbekannt',
|
|
|
|
UNKNOWN: 'Unbekannt',
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const playerNameRegex = /^(.*?)\s\(/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const vehicleNameEndRegex = /\s\(\w+:/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const sideRegex = /(side:\s(.*?)\))/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const magazineRegex = /(magazine:\s(.*?)\))/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const vehicleRegex = /(vehicle:\s(.*?)\))/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const categoryRegex = /(category:\s(.*?)\))/;
|
|
|
|
|
|
|
|
|
|
|
|
const parseWarLog = (lineArray, war) => {
|
|
|
|
const parseWarLog = (lineArray, war) => {
|
|
|
|
const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
|
|
|
|
const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
|
|
|
|
|
|
|
|
|
|
|
@ -61,7 +73,7 @@ const parseWarLog = (lineArray, war) => {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
stats.clean.push(line);
|
|
|
|
stats.clean.push(line);
|
|
|
|
|
|
|
|
|
|
|
|
const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.lastIndexOf('."'));
|
|
|
|
const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.search(/$/) - 1);
|
|
|
|
const shooter = getPlayerAndFractionFromString(shooterString);
|
|
|
|
const shooter = getPlayerAndFractionFromString(shooterString);
|
|
|
|
|
|
|
|
|
|
|
|
if (line.includes('Fahrzeug:')) {
|
|
|
|
if (line.includes('Fahrzeug:')) {
|
|
|
@ -78,7 +90,7 @@ const parseWarLog = (lineArray, war) => {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const targetString = line.substring(line.lastIndexOf(' --- ') + 5, line.lastIndexOf(' von:'));
|
|
|
|
const targetString = line.substring(line.lastIndexOf(' --- Einheit: ') + 14, line.lastIndexOf(' von:'));
|
|
|
|
const target = getPlayerAndFractionFromString(targetString);
|
|
|
|
const target = getPlayerAndFractionFromString(targetString);
|
|
|
|
stats.kills.push({
|
|
|
|
stats.kills.push({
|
|
|
|
war: war._id,
|
|
|
|
war: war._id,
|
|
|
@ -200,7 +212,8 @@ const parseWarLog = (lineArray, war) => {
|
|
|
|
const playerName = stats.players[i].name;
|
|
|
|
const playerName = stats.players[i].name;
|
|
|
|
stats.players[i]['respawn'] = stats.respawn.filter((res) => res.player === playerName).length;
|
|
|
|
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]['kill'] = stats.kills.filter(
|
|
|
|
|
|
|
|
(kill) => kill.shooter === playerName && !kill.friendlyFire).length;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: use vehicle class description from enum
|
|
|
|
// TODO: use vehicle class description from enum
|
|
|
|
stats.players[i]['vehicleLight'] = stats.vehicles.filter(
|
|
|
|
stats.players[i]['vehicleLight'] = stats.vehicles.filter(
|
|
|
@ -224,7 +237,8 @@ const parseWarLog = (lineArray, war) => {
|
|
|
|
|
|
|
|
|
|
|
|
stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length;
|
|
|
|
stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length;
|
|
|
|
|
|
|
|
|
|
|
|
stats.players[i]['sort'] = stats.players[i]['kill'] + stats.players[i]['revive'] + stats.players[i]['flagTouch']
|
|
|
|
stats.players[i]['sort'] = stats.players[i]['kill'] + stats.players[i]['revive'] +
|
|
|
|
|
|
|
|
stats.players[i]['flagTouch']
|
|
|
|
- stats.players[i]['friendlyFire'] - stats.players[i]['death'] - stats.players[i]['respawn'];
|
|
|
|
- stats.players[i]['friendlyFire'] - stats.players[i]['death'] - stats.players[i]['respawn'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -262,34 +276,81 @@ const getBudgetEntry = (budg, warId, warDate) => {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const getPlayerAndFractionFromString = (nameAndFractionString) => {
|
|
|
|
const getPlayerAndFractionFromString = (inputString) => {
|
|
|
|
const nameArray = nameAndFractionString.split(WHITESPACE);
|
|
|
|
const playerNameRegexMatch = playerNameRegex.exec(inputString);
|
|
|
|
const fraction = nameArray[nameArray.length - 1] !== '(ENEMY)' ?
|
|
|
|
const sideMatch = sideRegex.exec(inputString);
|
|
|
|
nameArray[nameArray.length - 1] === '(WEST)' ?
|
|
|
|
// const magazineMatch = magazineRegex.exec(inputString);
|
|
|
|
|
|
|
|
// const vehicleMatch = vehicleRegex.exec(inputString);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let name;
|
|
|
|
|
|
|
|
if (playerNameRegexMatch && playerNameRegexMatch.length >= 2) {
|
|
|
|
|
|
|
|
// NAME
|
|
|
|
|
|
|
|
name = playerNameRegexMatch[1];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let side;
|
|
|
|
|
|
|
|
if (sideMatch && sideMatch.length >= 3) {
|
|
|
|
|
|
|
|
// SIDE
|
|
|
|
|
|
|
|
side = sideMatch[2];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
const inputArray = inputString.split(WHITESPACE);
|
|
|
|
|
|
|
|
if (inputArray) {
|
|
|
|
|
|
|
|
side = inputArray[inputArray.length - 1].replace('(', '').replace(')', '');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (magazineMatch && magazineMatch.length >= 3) {
|
|
|
|
|
|
|
|
// MAGAZINE
|
|
|
|
|
|
|
|
// console.log(magazineMatch[2])
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (vehicleMatch && vehicleMatch.length >= 3 && vehicleMatch[2]) {
|
|
|
|
|
|
|
|
// let vehicle = vehicleMatch[2];
|
|
|
|
|
|
|
|
// if (new RegExp("\\(.*$").test(vehicle)) {
|
|
|
|
|
|
|
|
// vehicle = vehicle.concat(")");
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// VEHICLE
|
|
|
|
|
|
|
|
// console.log(vehicle)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let fraction;
|
|
|
|
|
|
|
|
if (side) {
|
|
|
|
|
|
|
|
fraction = side !== 'ENEMY' ? side === 'WEST' ?
|
|
|
|
'BLUFOR' : 'OPFOR' :
|
|
|
|
'BLUFOR' : 'OPFOR' :
|
|
|
|
undefined;
|
|
|
|
undefined;
|
|
|
|
const name = nameAndFractionString.substring(0, nameAndFractionString.indexOf(nameArray[nameArray.length - 1]) - 1);
|
|
|
|
}
|
|
|
|
// do not return player for 'Selbstverschulden' or 'Error: No unit'
|
|
|
|
|
|
|
|
|
|
|
|
// do not return player for 'Error: No unit'
|
|
|
|
if (name && name !== 'Error: No unit') {
|
|
|
|
if (name && name !== 'Error: No unit') {
|
|
|
|
return {name: name, fraction: fraction};
|
|
|
|
return {name: name.trim(), fraction: fraction};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const getVehicleAndFractionFromString = (nameClassFractionString) => {
|
|
|
|
const getVehicleAndFractionFromString = (nameClassFractionString) => {
|
|
|
|
const nameArray = nameClassFractionString.trim().split(WHITESPACE);
|
|
|
|
const sideMatch = sideRegex.exec(nameClassFractionString);
|
|
|
|
|
|
|
|
const categoryMatch = categoryRegex.exec(nameClassFractionString);
|
|
|
|
|
|
|
|
|
|
|
|
const vehicleFraction = nameArray[nameArray.length - 1];
|
|
|
|
// NAME
|
|
|
|
nameArray.pop();
|
|
|
|
const vehicleName = nameClassFractionString.substring(0,
|
|
|
|
const vehicleClassString = nameArray[nameArray.length - 1].replace('(', '').replace(')', '');
|
|
|
|
nameClassFractionString.indexOf(vehicleNameEndRegex.exec(nameClassFractionString)));
|
|
|
|
nameArray.pop();
|
|
|
|
|
|
|
|
const vehicleName = nameArray.join(WHITESPACE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// skip logging here - this is some basic equipment identifier (i.e. parachute)
|
|
|
|
let fraction;
|
|
|
|
if (vehicleFraction === 'OPF_F' || vehicleFraction === 'BLU_F' || vehicleClassString === VehicleClasses.UNKNOWN) {
|
|
|
|
if (sideMatch && sideMatch.length >= 3) {
|
|
|
|
return;
|
|
|
|
// SIDE
|
|
|
|
|
|
|
|
const side = sideMatch[2];
|
|
|
|
|
|
|
|
fraction = side === 'OPT_NATO' || side === 'OPT_NATO_T' || side === 'WEST' ? 'BLUFOR' : 'OPFOR';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const fraction = vehicleFraction === '(OPT_NATO)' || vehicleFraction === '(OPT_NATO_T)' ? 'BLUFOR' : 'OPFOR';
|
|
|
|
let vehicleClassString;
|
|
|
|
|
|
|
|
if (categoryMatch && categoryMatch.length >= 3) {
|
|
|
|
|
|
|
|
// CATEGORY
|
|
|
|
|
|
|
|
vehicleClassString = categoryMatch[2];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// skip logging here - this is some basic equipment identifier (i.e. parachute)
|
|
|
|
|
|
|
|
if (fraction === 'OPF_F' || fraction === 'BLU_F' || vehicleClassString === VehicleClasses.UNKNOWN) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let vehicleClass;
|
|
|
|
let vehicleClass;
|
|
|
|
for (const key in VehicleClasses) {
|
|
|
|
for (const key in VehicleClasses) {
|
|
|
@ -298,11 +359,13 @@ const getVehicleAndFractionFromString = (nameClassFractionString) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (vehicleName && fraction && vehicleClass) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
name: vehicleName,
|
|
|
|
name: vehicleName,
|
|
|
|
fraction: fraction,
|
|
|
|
fraction: fraction,
|
|
|
|
vehicleClass: vehicleClass,
|
|
|
|
vehicleClass: vehicleClass,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const transformMoneyString = (budgetString) => {
|
|
|
|
const transformMoneyString = (budgetString) => {
|
|
|
|