Merge branch 'release/v1.6.9' of hardi/opt-cc into master

pull/25/head
hardi 2018-02-03 12:23:53 +01:00 committed by HardiReady
commit 9fb865f4dc
4 changed files with 37 additions and 29 deletions

View File

@ -67,6 +67,9 @@ overview.route('/')
if (err) { if (err) {
return next(err); return next(err);
} }
// do not return empty squads
if (squadMembers.length > 0) {
const s = squad.toObject(); const s = squad.toObject();
s.members = squadMembers; s.members = squadMembers;
s.memberCount = squadMembers.length; s.memberCount = squadMembers.length;
@ -80,6 +83,8 @@ overview.route('/')
armyOverview.OPFOR.squads.push(s); armyOverview.OPFOR.squads.push(s);
countOpfor += s.members.length; countOpfor += s.members.length;
} }
}
callback(); callback();
}); });
}); });

View File

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

View File

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

View File

@ -66,7 +66,7 @@ export class WarDetailComponent {
this.fractionStatsInitialized = true; this.fractionStatsInitialized = true;
}); });
} }
window.scroll({left: 0, top: 0, behavior: 'smooth'}); window.scrollTo({left: 0, top: 0, behavior: 'smooth'});
} }
/** /**