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,19 +67,24 @@ overview.route('/')
if (err) {
return next(err);
}
const s = squad.toObject();
s.members = squadMembers;
s.memberCount = squadMembers.length;
if (s.fraction === 'BLUFOR') {
delete s.fraction;
armyOverview.BLUFOR.squads.push(s);
countBlufor += s.members.length;
}
if (s.fraction === 'OPFOR') {
delete s.fraction;
armyOverview.OPFOR.squads.push(s);
countOpfor += s.members.length;
// do not return empty squads
if (squadMembers.length > 0) {
const s = squad.toObject();
s.members = squadMembers;
s.memberCount = squadMembers.length;
if (s.fraction === 'BLUFOR') {
delete s.fraction;
armyOverview.BLUFOR.squads.push(s);
countBlufor += s.members.length;
}
if (s.fraction === 'OPFOR') {
delete s.fraction;
armyOverview.OPFOR.squads.push(s);
countOpfor += s.members.length;
}
}
callback();
});
});

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,

View File

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