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

pull/36/head v1.7.5
hardi 2018-06-06 19:16:58 +02:00 committed by Gogs
commit 7797397764
4 changed files with 95 additions and 29 deletions

View File

@ -11,6 +11,18 @@ const VehicleClasses = Object.freeze({
UNKNOWN: 'Unbekannt', UNKNOWN: 'Unbekannt',
}); });
const playerNameRegex = /^(.*?)\s\(/;
const vehicleNameEndRegex = /\s\(\w+:/;
const sideRegex = /(side:\s(.*?)\))/;
// const magazineRegex = /(magazine:\s(.*?)\))/;
// const vehicleRegex = /(vehicle:\s(.*?)\))/;
const categoryRegex = /(category:\s(.*?)\))/;
const parseWarLog = (lineArray, war) => { const parseWarLog = (lineArray, war) => {
const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \''; const NAME_TOO_LONG_ERROR = 'Error: ENAMETOOLONG: name too long, open \'';
@ -61,7 +73,7 @@ const parseWarLog = (lineArray, war) => {
*/ */
stats.clean.push(line); stats.clean.push(line);
const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.lastIndexOf('."')); const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.search(/$/) - 1);
const shooter = getPlayerAndFractionFromString(shooterString); const shooter = getPlayerAndFractionFromString(shooterString);
if (line.includes('Fahrzeug:')) { if (line.includes('Fahrzeug:')) {
@ -78,7 +90,7 @@ const parseWarLog = (lineArray, war) => {
}); });
} }
} else { } else {
const targetString = line.substring(line.lastIndexOf(' --- ') + 5, line.lastIndexOf(' von:')); const targetString = line.substring(line.lastIndexOf(' --- Einheit: ') + 14, line.lastIndexOf(' von:'));
const target = getPlayerAndFractionFromString(targetString); const target = getPlayerAndFractionFromString(targetString);
stats.kills.push({ stats.kills.push({
war: war._id, war: war._id,
@ -200,7 +212,8 @@ const parseWarLog = (lineArray, war) => {
const playerName = stats.players[i].name; const playerName = stats.players[i].name;
stats.players[i]['respawn'] = stats.respawn.filter((res) => res.player === playerName).length; stats.players[i]['respawn'] = stats.respawn.filter((res) => res.player === playerName).length;
stats.players[i]['kill'] = stats.kills.filter((kill) => kill.shooter === playerName && !kill.friendlyFire).length; stats.players[i]['kill'] = stats.kills.filter(
(kill) => kill.shooter === playerName && !kill.friendlyFire).length;
// TODO: use vehicle class description from enum // TODO: use vehicle class description from enum
stats.players[i]['vehicleLight'] = stats.vehicles.filter( stats.players[i]['vehicleLight'] = stats.vehicles.filter(
@ -224,7 +237,8 @@ const parseWarLog = (lineArray, war) => {
stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length; stats.players[i]['flagTouch'] = stats.flag.filter((flag) => flag.player === playerName).length;
stats.players[i]['sort'] = stats.players[i]['kill'] + stats.players[i]['revive'] + stats.players[i]['flagTouch'] stats.players[i]['sort'] = stats.players[i]['kill'] + stats.players[i]['revive'] +
stats.players[i]['flagTouch']
- stats.players[i]['friendlyFire'] - stats.players[i]['death'] - stats.players[i]['respawn']; - stats.players[i]['friendlyFire'] - stats.players[i]['death'] - stats.players[i]['respawn'];
} }
@ -262,34 +276,81 @@ const getBudgetEntry = (budg, warId, warDate) => {
}; };
}; };
const getPlayerAndFractionFromString = (nameAndFractionString) => { const getPlayerAndFractionFromString = (inputString) => {
const nameArray = nameAndFractionString.split(WHITESPACE); const playerNameRegexMatch = playerNameRegex.exec(inputString);
const fraction = nameArray[nameArray.length - 1] !== '(ENEMY)' ? const sideMatch = sideRegex.exec(inputString);
nameArray[nameArray.length - 1] === '(WEST)' ? // const magazineMatch = magazineRegex.exec(inputString);
// const vehicleMatch = vehicleRegex.exec(inputString);
let name;
if (playerNameRegexMatch && playerNameRegexMatch.length >= 2) {
// NAME
name = playerNameRegexMatch[1];
}
let side;
if (sideMatch && sideMatch.length >= 3) {
// SIDE
side = sideMatch[2];
} else {
const inputArray = inputString.split(WHITESPACE);
if (inputArray) {
side = inputArray[inputArray.length - 1].replace('(', '').replace(')', '');
}
}
// if (magazineMatch && magazineMatch.length >= 3) {
// MAGAZINE
// console.log(magazineMatch[2])
// }
// if (vehicleMatch && vehicleMatch.length >= 3 && vehicleMatch[2]) {
// let vehicle = vehicleMatch[2];
// if (new RegExp("\\(.*$").test(vehicle)) {
// vehicle = vehicle.concat(")");
// }
// VEHICLE
// console.log(vehicle)
// }
let fraction;
if (side) {
fraction = side !== 'ENEMY' ? side === 'WEST' ?
'BLUFOR' : 'OPFOR' : 'BLUFOR' : 'OPFOR' :
undefined; undefined;
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 'Error: No unit'
if (name && name !== 'Error: No unit') { if (name && name !== 'Error: No unit') {
return {name: name, fraction: fraction}; return {name: name.trim(), fraction: fraction};
} }
}; };
const getVehicleAndFractionFromString = (nameClassFractionString) => { const getVehicleAndFractionFromString = (nameClassFractionString) => {
const nameArray = nameClassFractionString.trim().split(WHITESPACE); const sideMatch = sideRegex.exec(nameClassFractionString);
const categoryMatch = categoryRegex.exec(nameClassFractionString);
const vehicleFraction = nameArray[nameArray.length - 1]; // NAME
nameArray.pop(); const vehicleName = nameClassFractionString.substring(0,
const vehicleClassString = nameArray[nameArray.length - 1].replace('(', '').replace(')', ''); nameClassFractionString.indexOf(vehicleNameEndRegex.exec(nameClassFractionString)));
nameArray.pop();
const vehicleName = nameArray.join(WHITESPACE);
// skip logging here - this is some basic equipment identifier (i.e. parachute) let fraction;
if (vehicleFraction === 'OPF_F' || vehicleFraction === 'BLU_F' || vehicleClassString === VehicleClasses.UNKNOWN) { if (sideMatch && sideMatch.length >= 3) {
return; // SIDE
const side = sideMatch[2];
fraction = side === 'OPT_NATO' || side === 'OPT_NATO_T' || side === 'WEST' ? 'BLUFOR' : 'OPFOR';
} }
const fraction = vehicleFraction === '(OPT_NATO)' || vehicleFraction === '(OPT_NATO_T)' ? 'BLUFOR' : 'OPFOR'; let vehicleClassString;
if (categoryMatch && categoryMatch.length >= 3) {
// CATEGORY
vehicleClassString = categoryMatch[2];
}
// skip logging here - this is some basic equipment identifier (i.e. parachute)
if (fraction === 'OPF_F' || fraction === 'BLU_F' || vehicleClassString === VehicleClasses.UNKNOWN) {
return;
}
let vehicleClass; let vehicleClass;
for (const key in VehicleClasses) { for (const key in VehicleClasses) {
@ -298,11 +359,13 @@ const getVehicleAndFractionFromString = (nameClassFractionString) => {
} }
} }
return { if (vehicleName && fraction && vehicleClass) {
name: vehicleName, return {
fraction: fraction, name: vehicleName,
vehicleClass: vehicleClass, fraction: fraction,
}; vehicleClass: vehicleClass,
};
}
}; };
const transformMoneyString = (budgetString) => { const transformMoneyString = (budgetString) => {

View File

@ -1,4 +1,4 @@
<code_scheme name="OPT-CC" version="173"> <code_scheme name="OPT-CC copy" version="173">
<option name="FORMATTER_TAGS_ENABLED" value="true" /> <option name="FORMATTER_TAGS_ENABLED" value="true" />
<JSCodeStyleSettings> <JSCodeStyleSettings>
<option name="USE_CHAINED_CALLS_GROUP_INDENTS" value="true" /> <option name="USE_CHAINED_CALLS_GROUP_INDENTS" value="true" />

View File

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

View File

@ -16,6 +16,9 @@
<div class="collapse navbar-collapse" id="mynavbar"> <div class="collapse navbar-collapse" id="mynavbar">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li routerLinkActive="active">
<a href="https://www.opt4.net/dashboard" class="link">Zum Forum</a>
</li>
<li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active"> <li *ngIf="!loginService.isLoggedIn()" routerLinkActive="active">
<a routerLink='{{config.loginPath}}' class="link">Login</a> <a routerLink='{{config.loginPath}}' class="link">Login</a>
</li> </li>