reactivate respawn parse

pull/24/head
HardiReady 2018-02-03 11:34:46 +01:00
parent 5d1ac86b02
commit e2d522ac7c
2 changed files with 19 additions and 16 deletions

View File

@ -2,8 +2,11 @@
const playerArrayContains = require('./util').playerArrayContains;
const WHITESPACE = ' ';
const parseWarLog = (lineArray, war) => {
const nameToLongError = 'Error: ENAMETOOLONG: name too long, open \'';
const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
const stats = {
war: war,
clean: [],
@ -29,8 +32,8 @@ const parseWarLog = (lineArray, war) => {
/**
* sanitize nameTooLongError coming up in first line
*/
if (line.includes(nameToLongError)) {
line = line.substring(line.indexOf(nameToLongError) + nameToLongError.length);
if (line.includes(NAME_TOO_LONG_ERROR)) {
line = line.substring(line.indexOf(NAME_TOO_LONG_ERROR) + NAME_TOO_LONG_ERROR.length);
}
/**
@ -45,7 +48,7 @@ const parseWarLog = (lineArray, war) => {
stats.kills.push({
war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]),
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
shooter: shooter ? shooter.name : null,
target: target ? target.name : null,
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
@ -58,7 +61,7 @@ const parseWarLog = (lineArray, war) => {
*/
else if (line.includes('(Budget)')) {
stats.clean.push(line);
const budg = line.split(' ');
const budg = line.split(WHITESPACE);
if (line.includes('Startbudget')) {
stats.war['budgetBlufor'] = transformMoneyString(budg[9]);
stats.war['budgetOpfor'] = transformMoneyString(budg[12].slice(0,-1));
@ -85,7 +88,7 @@ const parseWarLog = (lineArray, war) => {
stats.flag.push({
war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]),
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
player: playerName,
flagFraction: flagFraction,
capture: capture
@ -97,7 +100,7 @@ const parseWarLog = (lineArray, war) => {
*/
else if (line.includes('(Punkte)')) {
stats.clean.push(line);
const pt = line.split(' ');
const pt = line.split(WHITESPACE);
if (line.includes('Endpunktestand')) {
stats.war['ptBlufor'] = parseInt(pt[9]);
@ -112,11 +115,11 @@ const parseWarLog = (lineArray, war) => {
/**
* RESPAWN
*/
// else if (line.includes('Respawn')) {
// const resp = line.split(' ');
// const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('- Kosten') -1);
// stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date));
// }
else if (line.includes('(Respawn)')) {
const resp = line.split(WHITESPACE);
const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('- Kosten') -1);
stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date));
}
/**
* REVIVE
@ -132,7 +135,7 @@ const parseWarLog = (lineArray, war) => {
stats.revive.push({
war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]),
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
stabilized: stabilized,
medic: medic.name,
patient: patient.name,
@ -153,7 +156,7 @@ const parseWarLog = (lineArray, war) => {
stats.transport.push({
war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]),
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
driver: driver ? driver.name : null,
passenger: passenger ? passenger.name : null,
fraction: driver ? driver.fraction : 'NONE',
@ -217,7 +220,7 @@ const getBudgetEntry = (budg, warId, warDate) => {
};
const getPlayerAndFractionFromString = (nameAndFractionString) => {
const nameArray = nameAndFractionString.split(' ');
const nameArray = nameAndFractionString.split(WHITESPACE);
const fraction = nameArray[nameArray.length - 1] !== '(ENEMY)' ? nameArray[nameArray.length - 1] === '(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'

View File

@ -1,6 +1,6 @@
{
"name": "opt-cc",
"version": "1.6.8",
"version": "1.6.9",
"license": "MIT",
"author": "Florian Hartwich <hardi@noarch.de>",
"private": true,