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

pull/44/head
hardi 2018-06-10 19:38:25 +02:00 committed by Gogs
commit 1ac58ea71a
7 changed files with 40 additions and 13 deletions

View File

@ -71,6 +71,7 @@
#LogVehicle (Log) #LogVehicle (Log)
## Properties ## Properties
+ shooter: `HardiReady` (string, required) - name of player who shot the vehicle + shooter: `HardiReady` (string, required) - name of player who shot the vehicle
+ additionalShooter: [`[GNC]Paolo`, `Dominik`] (array[string], required) - additional crew members of shooter vehicle
+ target: `T-100` (string, required) - name of the vehicle + target: `T-100` (string, required) - name of the vehicle
+ fraction: `BLUFOR` (enum, required) - fraction of the shooter + fraction: `BLUFOR` (enum, required) - fraction of the shooter
+ Members + Members

View File

@ -16,6 +16,9 @@ const LogVehicleKillSchema = new Schema({
shooter: { shooter: {
type: String, type: String,
}, },
additionalShooter: {
type: [String],
},
target: { target: {
type: String, type: String,
required: true, required: true,

View File

@ -64,6 +64,7 @@ campaigns.route('/:id')
} }
WarModel.find({campaign: req.params.id}).remove().exec(); WarModel.find({campaign: req.params.id}).remove().exec();
// TODO: remove all the war logs from fs here!!! // TODO: remove all the war logs from fs here!!!
// TODO: remove all LOG entries from DB!!!
res.locals.processed = true; res.locals.processed = true;
next(); next();
}); });

View File

@ -189,6 +189,7 @@ wars.route('/:id')
// delete linked appearances // delete linked appearances
PlayerModel.find({warId: item._id}).remove().exec(); PlayerModel.find({warId: item._id}).remove().exec();
LogKillModel.find({war: item._id}).remove().exec(); LogKillModel.find({war: item._id}).remove().exec();
LogVehicleKillModel.find({war: item._id}).remove().exec();
LogRespawnModel.find({war: item._id}).remove().exec(); LogRespawnModel.find({war: item._id}).remove().exec();
LogReviveModel.find({war: item._id}).remove().exec(); LogReviveModel.find({war: item._id}).remove().exec();
LogFlagModel.find({war: item._id}).remove().exec(); LogFlagModel.find({war: item._id}).remove().exec();

View File

@ -11,7 +11,7 @@ const VehicleClasses = Object.freeze({
UNKNOWN: 'Unbekannt', UNKNOWN: 'Unbekannt',
}); });
const playerNameRegex = /^(.*?)\s\(/; const playerNameRegex = /(^|,\s)(.*?)\s\(/g;
const vehicleNameEndRegex = /\s\(\w+:/; const vehicleNameEndRegex = /\s\(\w+:/;
@ -80,14 +80,20 @@ const parseWarLog = (lineArray, war) => {
const targetString = line.substring(line.lastIndexOf(' --- Fahrzeug: ') + 15, line.lastIndexOf(' von:')); const targetString = line.substring(line.lastIndexOf(' --- Fahrzeug: ') + 15, line.lastIndexOf(' von:'));
const target = getVehicleAndFractionFromString(targetString); const target = getVehicleAndFractionFromString(targetString);
if (target && shooter && target.fraction !== shooter.fraction) { if (target && shooter && target.fraction !== shooter.fraction) {
stats.vehicles.push({ const vehicleKill = {
war: war._id, war: war._id,
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]), time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
shooter: shooter ? shooter.name : null,
target: target ? target.name : null, target: target ? target.name : null,
fraction: shooter ? shooter.fraction : 'NONE', fraction: shooter ? shooter.fraction : 'NONE',
vehicleClass: target.vehicleClass, vehicleClass: target.vehicleClass,
}); };
if (shooter && shooter.name instanceof Array) {
vehicleKill.shooter = shooter.name[0];
vehicleKill.additionalShooter = shooter.name.slice(1, shooter.name.length);
} else {
vehicleKill.shooter = shooter ? shooter.name : null;
}
stats.vehicles.push(vehicleKill);
} }
} else { } else {
const targetString = line.substring(line.lastIndexOf(' --- Einheit: ') + 14, line.lastIndexOf(' von:')); const targetString = line.substring(line.lastIndexOf(' --- Einheit: ') + 14, line.lastIndexOf(' von:'));
@ -217,15 +223,18 @@ const parseWarLog = (lineArray, war) => {
// 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(
(vehicle) => vehicle.shooter === playerName && vehicle.vehicleClass === 'LIGHT' && (vehicle) => (vehicle.shooter === playerName || vehicle.additionalShooter.indexOf(playerName) > -1) &&
vehicle.vehicleClass === 'LIGHT' &&
VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length;
stats.players[i]['vehicleHeavy'] = stats.vehicles.filter( stats.players[i]['vehicleHeavy'] = stats.vehicles.filter(
(vehicle) => vehicle.shooter === playerName && vehicle.vehicleClass === 'HEAVY' && (vehicle) => (vehicle.shooter === playerName || vehicle.additionalShooter.indexOf(playerName) > -1) &&
vehicle.vehicleClass === 'HEAVY' &&
VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length;
stats.players[i]['vehicleAir'] = stats.vehicles.filter( stats.players[i]['vehicleAir'] = stats.vehicles.filter(
(vehicle) => vehicle.shooter === playerName && vehicle.vehicleClass === 'AIR' && (vehicle) => (vehicle.shooter === playerName || vehicle.additionalShooter.indexOf(playerName) > -1) &&
vehicle.vehicleClass === 'AIR' &&
VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length;
stats.players[i]['friendlyFire'] = stats.kills.filter( stats.players[i]['friendlyFire'] = stats.kills.filter(
@ -279,18 +288,27 @@ const getBudgetEntry = (budg, warId, warDate) => {
const getPlayerAndFractionFromString = (inputString) => { const getPlayerAndFractionFromString = (inputString) => {
const playerNameRegexMatch = playerNameRegex.exec(inputString); const playerNameRegexMatch = playerNameRegex.exec(inputString);
const sideMatch = sideRegex.exec(inputString); const sideMatch = sideRegex.exec(inputString);
// const magazineMatch = magazineRegex.exec(inputString);
// const vehicleMatch = vehicleRegex.exec(inputString);
// SINGLE PLAYER NAME
let name; let name;
if (playerNameRegexMatch && playerNameRegexMatch.length >= 2) { if (playerNameRegexMatch && playerNameRegexMatch.length >= 2) {
// NAME // NAME
name = playerNameRegexMatch[1]; name = playerNameRegexMatch[2].trim();
}
// ADDITIONAL PLAYER NAMES
let additionalPlayerMatch;
while ((additionalPlayerMatch = playerNameRegex.exec(inputString)) !== null) {
const addPlayer = additionalPlayerMatch[0].replace(/^,\s/, '').replace(/\s\($/, '').trim();
if (name instanceof Array) {
name.push(addPlayer);
} else {
name = [name, addPlayer];
}
} }
// PLAYER FRACTION
let side; let side;
if (sideMatch && sideMatch.length >= 3) { if (sideMatch && sideMatch.length >= 3) {
// SIDE
side = sideMatch[2]; side = sideMatch[2];
} else { } else {
const inputArray = inputString.split(WHITESPACE); const inputArray = inputString.split(WHITESPACE);
@ -299,6 +317,9 @@ const getPlayerAndFractionFromString = (inputString) => {
} }
} }
// const magazineMatch = magazineRegex.exec(inputString);
// const vehicleMatch = vehicleRegex.exec(inputString);
// if (magazineMatch && magazineMatch.length >= 3) { // if (magazineMatch && magazineMatch.length >= 3) {
// MAGAZINE // MAGAZINE
// console.log(magazineMatch[2]) // console.log(magazineMatch[2])
@ -322,7 +343,7 @@ const getPlayerAndFractionFromString = (inputString) => {
// do not return player for '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.trim(), fraction: fraction}; return {name: name, fraction: fraction};
} }
}; };

Binary file not shown.

View File

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