|
|
|
@ -11,6 +11,18 @@ const VehicleClasses = Object.freeze({
|
|
|
|
|
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 NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
|
|
|
|
|
|
|
|
|
@ -61,7 +73,7 @@ const parseWarLog = (lineArray, war) => {
|
|
|
|
|
*/
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
if (line.includes('Fahrzeug:')) {
|
|
|
|
@ -78,7 +90,7 @@ const parseWarLog = (lineArray, war) => {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} 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);
|
|
|
|
|
stats.kills.push({
|
|
|
|
|
war: war._id,
|
|
|
|
@ -200,7 +212,8 @@ const parseWarLog = (lineArray, war) => {
|
|
|
|
|
const playerName = stats.players[i].name;
|
|
|
|
|
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
|
|
|
|
|
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]['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'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -262,34 +276,81 @@ const getBudgetEntry = (budg, warId, warDate) => {
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getPlayerAndFractionFromString = (nameAndFractionString) => {
|
|
|
|
|
const nameArray = nameAndFractionString.split(WHITESPACE);
|
|
|
|
|
const fraction = nameArray[nameArray.length - 1] !== '(ENEMY)' ?
|
|
|
|
|
nameArray[nameArray.length - 1] === '(WEST)' ?
|
|
|
|
|
const getPlayerAndFractionFromString = (inputString) => {
|
|
|
|
|
const playerNameRegexMatch = playerNameRegex.exec(inputString);
|
|
|
|
|
const sideMatch = sideRegex.exec(inputString);
|
|
|
|
|
// 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' :
|
|
|
|
|
undefined;
|
|
|
|
|
const name = nameAndFractionString.substring(0, nameAndFractionString.indexOf(nameArray[nameArray.length - 1]) - 1);
|
|
|
|
|
// do not return player for 'Selbstverschulden' or 'Error: No unit'
|
|
|
|
|
undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// do not return player for 'Error: No unit'
|
|
|
|
|
if (name && name !== 'Error: No unit') {
|
|
|
|
|
return {name: name, fraction: fraction};
|
|
|
|
|
return {name: name.trim(), fraction: fraction};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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];
|
|
|
|
|
nameArray.pop();
|
|
|
|
|
const vehicleClassString = nameArray[nameArray.length - 1].replace('(', '').replace(')', '');
|
|
|
|
|
nameArray.pop();
|
|
|
|
|
const vehicleName = nameArray.join(WHITESPACE);
|
|
|
|
|
// NAME
|
|
|
|
|
const vehicleName = nameClassFractionString.substring(0,
|
|
|
|
|
nameClassFractionString.indexOf(vehicleNameEndRegex.exec(nameClassFractionString)));
|
|
|
|
|
|
|
|
|
|
// skip logging here - this is some basic equipment identifier (i.e. parachute)
|
|
|
|
|
if (vehicleFraction === 'OPF_F' || vehicleFraction === 'BLU_F' || vehicleClassString === VehicleClasses.UNKNOWN) {
|
|
|
|
|
return;
|
|
|
|
|
let fraction;
|
|
|
|
|
if (sideMatch && sideMatch.length >= 3) {
|
|
|
|
|
// 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;
|
|
|
|
|
for (const key in VehicleClasses) {
|
|
|
|
@ -298,11 +359,13 @@ const getVehicleAndFractionFromString = (nameClassFractionString) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
name: vehicleName,
|
|
|
|
|
fraction: fraction,
|
|
|
|
|
vehicleClass: vehicleClass,
|
|
|
|
|
};
|
|
|
|
|
if (vehicleName && fraction && vehicleClass) {
|
|
|
|
|
return {
|
|
|
|
|
name: vehicleName,
|
|
|
|
|
fraction: fraction,
|
|
|
|
|
vehicleClass: vehicleClass,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const transformMoneyString = (budgetString) => {
|
|
|
|
|