Fix log parsing player name resolve (CC-86)

pull/53/head
HardiReady 2019-02-14 20:46:22 +01:00
parent 4a96b99619
commit 9467fc5699
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "opt-cc",
"version": "1.9.0",
"version": "1.9.1",
"author": "Florian Hartwich <hardi@noarch.de>",
"private": true,
"scripts": {

View File

@ -417,7 +417,12 @@ const getBudgetEntry = (budg, warId, warDate) => {
const getPlayerInfoFromString = (inputString) => {
const resPlayer = {};
const playerNameRegexMatch = playerNameRegex.exec(inputString);
let playerNameRegexMatch = playerNameRegex.exec(inputString);
// https://stackoverflow.com/questions/18462784/why-is-javascript-regex-matching-every-second-time
if (!playerNameRegexMatch) {
playerNameRegexMatch = playerNameRegex.exec(inputString);
}
const sideMatch = sideRegex.exec(inputString);
// SINGLE PLAYER NAME
@ -426,11 +431,11 @@ const getPlayerInfoFromString = (inputString) => {
name = playerNameRegexMatch[2].trim();
// do not return player for 'unbekannt' or 'Error: No unit'
if (!name || name === 'unbekannt' || name === 'Error: No unit' || name === 'Selbstverschulden.') {
return;
return {name: 'UNKNOWN', fraction: 'NONE'};
}
resPlayer.name = name;
} else {
return;
return {name: 'UNKNOWN', fraction: 'NONE'};
}
// ADDITIONAL PLAYER NAMES