Do not process/count duplicated flagTouch

pull/46/head
HardiReady 2018-10-18 20:23:29 +02:00
parent 21e2d81b06
commit 14c4cf68ff
1 changed files with 24 additions and 9 deletions

View File

@ -24,6 +24,10 @@ const vehicleRegex = /(vehicle:\s(.*?)\))/;
const categoryRegex = /(category:\s(.*?)\))/;
const parseWarLog = (lineArray, war) => {
let flagBlufor = true;
let flagOpfor = true;
const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
const stats = {
@ -164,18 +168,29 @@ const parseWarLog = (lineArray, war) => {
/**
* FLAG
*/
stats.clean.push(line);
const playerName = line.substring(line.lastIndexOf('rt von ') + 7).slice(0, -1);
const flagFraction = line.includes('NATO Flagge') ? 'BLUFOR' : 'OPFOR';
const capture = !!line.includes('Flagge erobert');
stats.flag.push({
war: war._id,
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
player: playerName,
flagFraction: flagFraction,
capture: capture,
});
if ((flagFraction === 'BLUFOR' && ((capture && flagBlufor) || (!capture && !flagBlufor))) ||
(flagFraction === 'OPFOR' && ((capture && flagOpfor) || (!capture && !flagOpfor)))) {
stats.clean.push(line);
const playerName = line.substring(line.lastIndexOf('rt von ') + 7).slice(0, -1);
if (flagFraction === 'BLUFOR') {
flagBlufor = !capture;
} else if (flagFraction === 'OPFOR') {
flagOpfor = !capture;
}
stats.flag.push({
war: war._id,
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
player: playerName,
flagFraction: flagFraction,
capture: capture,
});
}
} else if (line.includes('(Punkte)')) {
/**
* POINTS