diff --git a/api/apib/data_structures/_log.apib b/api/apib/data_structures/_log.apib index 752028e..7b44d5d 100644 --- a/api/apib/data_structures/_log.apib +++ b/api/apib/data_structures/_log.apib @@ -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 diff --git a/api/models/logs/vehicle.js b/api/models/logs/vehicle.js index 704d96e..e360e00 100644 --- a/api/models/logs/vehicle.js +++ b/api/models/logs/vehicle.js @@ -16,6 +16,9 @@ const LogVehicleKillSchema = new Schema({ shooter: { type: String, }, + additionalShooter: { + type: [String], + }, target: { type: String, required: true, diff --git a/api/routes/campaigns.js b/api/routes/campaigns.js index 573b74b..3155a88 100644 --- a/api/routes/campaigns.js +++ b/api/routes/campaigns.js @@ -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(); }); diff --git a/api/routes/wars.js b/api/routes/wars.js index 65b04d2..cf57b6a 100644 --- a/api/routes/wars.js +++ b/api/routes/wars.js @@ -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(); diff --git a/api/tools/log-parse-tool.js b/api/tools/log-parse-tool.js index cf6e311..661746b 100644 --- a/api/tools/log-parse-tool.js +++ b/api/tools/log-parse-tool.js @@ -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}; } }; diff --git a/docs/mongo-db-schema.odg b/docs/mongo-db-schema.odg index 200c170..0287454 100644 Binary files a/docs/mongo-db-schema.odg and b/docs/mongo-db-schema.odg differ diff --git a/package.json b/package.json index 0dc3b8c..9a46c82 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opt-cc", - "version": "1.7.5", + "version": "1.7.6", "author": "Florian Hartwich ", "private": true, "scripts": {