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 categoryRegex = /(category:\s(.*?)\))/;
const parseWarLog = (lineArray, war) => { const parseWarLog = (lineArray, war) => {
let flagBlufor = true;
let flagOpfor = true;
const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \''; const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
const stats = { const stats = {
@ -164,11 +168,21 @@ const parseWarLog = (lineArray, war) => {
/** /**
* FLAG * 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 flagFraction = line.includes('NATO Flagge') ? 'BLUFOR' : 'OPFOR';
const capture = !!line.includes('Flagge erobert'); const capture = !!line.includes('Flagge erobert');
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({ stats.flag.push({
war: war._id, war: war._id,
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]), time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
@ -176,6 +190,7 @@ const parseWarLog = (lineArray, war) => {
flagFraction: flagFraction, flagFraction: flagFraction,
capture: capture, capture: capture,
}); });
}
} else if (line.includes('(Punkte)')) { } else if (line.includes('(Punkte)')) {
/** /**
* POINTS * POINTS