Merge branch 'release/v1.7.6' of hardi/opt-cc into master
commit
1ac58ea71a
|
@ -71,6 +71,7 @@
|
|||
#LogVehicle (Log)
|
||||
## Properties
|
||||
+ 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
|
||||
+ fraction: `BLUFOR` (enum, required) - fraction of the shooter
|
||||
+ Members
|
||||
|
|
|
@ -16,6 +16,9 @@ const LogVehicleKillSchema = new Schema({
|
|||
shooter: {
|
||||
type: String,
|
||||
},
|
||||
additionalShooter: {
|
||||
type: [String],
|
||||
},
|
||||
target: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
|
|
@ -64,6 +64,7 @@ campaigns.route('/:id')
|
|||
}
|
||||
WarModel.find({campaign: req.params.id}).remove().exec();
|
||||
// TODO: remove all the war logs from fs here!!!
|
||||
// TODO: remove all LOG entries from DB!!!
|
||||
res.locals.processed = true;
|
||||
next();
|
||||
});
|
||||
|
|
|
@ -189,6 +189,7 @@ wars.route('/:id')
|
|||
// delete linked appearances
|
||||
PlayerModel.find({warId: 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();
|
||||
LogReviveModel.find({war: item._id}).remove().exec();
|
||||
LogFlagModel.find({war: item._id}).remove().exec();
|
||||
|
|
|
@ -11,7 +11,7 @@ const VehicleClasses = Object.freeze({
|
|||
UNKNOWN: 'Unbekannt',
|
||||
});
|
||||
|
||||
const playerNameRegex = /^(.*?)\s\(/;
|
||||
const playerNameRegex = /(^|,\s)(.*?)\s\(/g;
|
||||
|
||||
const vehicleNameEndRegex = /\s\(\w+:/;
|
||||
|
||||
|
@ -80,14 +80,20 @@ const parseWarLog = (lineArray, war) => {
|
|||
const targetString = line.substring(line.lastIndexOf(' --- Fahrzeug: ') + 15, line.lastIndexOf(' von:'));
|
||||
const target = getVehicleAndFractionFromString(targetString);
|
||||
if (target && shooter && target.fraction !== shooter.fraction) {
|
||||
stats.vehicles.push({
|
||||
const vehicleKill = {
|
||||
war: war._id,
|
||||
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
|
||||
shooter: shooter ? shooter.name : null,
|
||||
target: target ? target.name : null,
|
||||
fraction: shooter ? shooter.fraction : 'NONE',
|
||||
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 {
|
||||
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
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
stats.players[i]['friendlyFire'] = stats.kills.filter(
|
||||
|
@ -279,18 +288,27 @@ const getBudgetEntry = (budg, warId, warDate) => {
|
|||
const getPlayerAndFractionFromString = (inputString) => {
|
||||
const playerNameRegexMatch = playerNameRegex.exec(inputString);
|
||||
const sideMatch = sideRegex.exec(inputString);
|
||||
// const magazineMatch = magazineRegex.exec(inputString);
|
||||
// const vehicleMatch = vehicleRegex.exec(inputString);
|
||||
|
||||
// SINGLE PLAYER NAME
|
||||
let name;
|
||||
if (playerNameRegexMatch && playerNameRegexMatch.length >= 2) {
|
||||
// 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;
|
||||
if (sideMatch && sideMatch.length >= 3) {
|
||||
// SIDE
|
||||
side = sideMatch[2];
|
||||
} else {
|
||||
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) {
|
||||
// MAGAZINE
|
||||
// console.log(magazineMatch[2])
|
||||
|
@ -322,7 +343,7 @@ const getPlayerAndFractionFromString = (inputString) => {
|
|||
|
||||
// do not return player for 'Error: No unit'
|
||||
if (name && name !== 'Error: No unit') {
|
||||
return {name: name.trim(), fraction: fraction};
|
||||
return {name: name, fraction: fraction};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "opt-cc",
|
||||
"version": "1.7.5",
|
||||
"version": "1.7.6",
|
||||
"author": "Florian Hartwich <hardi@noarch.de>",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
|
Loading…
Reference in New Issue