CC-93: parse boat kills from logs, MVP

release/v1.9.8
HardiReady 2020-04-19 12:47:22 +02:00
parent 91d5095890
commit d9b0b2153e
6 changed files with 42 additions and 16 deletions

View File

@ -85,6 +85,7 @@
+ `LIGHT` + `LIGHT`
+ `HEAVY` + `HEAVY`
+ `AIR` + `AIR`
+ `BOAT`
+ `UNKNOWN` + `UNKNOWN`
+ shooterVehicle: `FV-720 Mora` (string, optional) - vehicle in whiock the shooting player sat + shooterVehicle: `FV-720 Mora` (string, optional) - vehicle in whiock the shooting player sat
+ magazine: `30 mm APFSDS` (string, optional) - magazine name used to execute the kill + magazine: `30 mm APFSDS` (string, optional) - magazine name used to execute the kill

View File

@ -10,6 +10,7 @@ Basic player statistic information object
+ vehicleLight: 1 (number, required) - sum of light vehicle kills + vehicleLight: 1 (number, required) - sum of light vehicle kills
+ vehicleHeavy: 1 (number, required) - sum of heavy vehicle kills + vehicleHeavy: 1 (number, required) - sum of heavy vehicle kills
+ vehicleAir: 0 (number, required) - sum of air vehicle kills + vehicleAir: 0 (number, required) - sum of air vehicle kills
+ vehicleBoat: 0 (number, required) - sum of boat vehicle kills
+ death: 3 (number, required) - sum of deaths + death: 3 (number, required) - sum of deaths
+ respawn: 2 (number, required) - sum of respawns + respawn: 2 (number, required) - sum of respawns
+ flagTouch: 1 (number, required) - sum of flag captures + flagTouch: 1 (number, required) - sum of flag captures

View File

@ -30,7 +30,7 @@ const LogVehicleKillSchema = new Schema({
}, },
vehicleClass: { vehicleClass: {
type: String, type: String,
enum: ['LIGHT', 'HEAVY', 'AIR', 'UNKNOWN'], enum: ['LIGHT', 'HEAVY', 'AIR', 'BOAT', 'UNKNOWN'],
required: true, required: true,
}, },
magazine: { magazine: {

View File

@ -42,6 +42,12 @@ const PlayerSchema = new Schema({
set: (v) => Math.round(v), set: (v) => Math.round(v),
required: true, required: true,
}, },
vehicleBoat: {
type: Number,
get: (v) => Math.round(v),
set: (v) => Math.round(v),
required: true,
},
death: { death: {
type: Number, type: Number,
get: (v) => Math.round(v), get: (v) => Math.round(v),

View File

@ -172,6 +172,11 @@ wars.route('/:id')
return next(err); return next(err);
} }
// TODO: temp solution for CC-93 - add boat kills to light vehicle kills until FE available
items.forEach((player) => {
player.vehicleLight = player.vehicleLight + player.vehicleBoat;
});
const responseObj = item.toObject(); const responseObj = item.toObject();
responseObj.players = items; responseObj.players = items;
res.locals.items = responseObj; res.locals.items = responseObj;

View File

@ -8,6 +8,7 @@ const VehicleClasses = Object.freeze({
LIGHT: 'Leicht', LIGHT: 'Leicht',
HEAVY: 'Schwer', HEAVY: 'Schwer',
AIR: 'Flug', AIR: 'Flug',
BOAT: 'Boot',
UNKNOWN: 'Unbekannt', UNKNOWN: 'Unbekannt',
}); });
@ -73,6 +74,8 @@ const parseWarLog = (lineArray, war) => {
'Tempest-Transporter', 'Tempest-Transporter (abgedeckt)', 'Tempest Sanitätsfahrzeug', 'Tempest-Transporter', 'Tempest-Transporter (abgedeckt)', 'Tempest Sanitätsfahrzeug',
'Remote Designator [CSAT]', 'UBF Saif', 'Remote Designator [CSAT]', 'UBF Saif',
'Quad Bike', 'HuntIR', 'Offroad', 'Quad Bike', 'HuntIR', 'Offroad',
// boats
'RHIB', 'Kampfboot', 'SDV',
]; ];
const addPlayerIfNotExists = (inputPlayer, steamUUID) => { const addPlayerIfNotExists = (inputPlayer, steamUUID) => {
@ -80,6 +83,10 @@ const parseWarLog = (lineArray, war) => {
if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) { if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) {
player['warId'] = war._id; player['warId'] = war._id;
player['steamUUID'] = steamUUID; player['steamUUID'] = steamUUID;
player['vehicleLight'] = 0;
player['vehicleHeavy'] = 0;
player['vehicleAir'] = 0;
player['vehicleBoat'] = 0;
stats.players.push(player); stats.players.push(player);
} }
}; };
@ -335,21 +342,27 @@ const parseWarLog = (lineArray, war) => {
stats.players[i]['kill'] = stats.kills.filter( stats.players[i]['kill'] = stats.kills.filter(
(kill) => kill.shooter === playerName && !kill.friendlyFire).length; (kill) => kill.shooter === playerName && !kill.friendlyFire).length;
// TODO: use vehicle class description from enum stats.vehicles
stats.players[i]['vehicleLight'] = stats.vehicles.filter( .filter((vehicle) => VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0)
(vehicle) => (vehicle.shooter === playerName || .forEach((vehicle) => {
(vehicle.additionalShooter && vehicle.additionalShooter.indexOf(playerName)) > -1) && vehicle.vehicleClass === if (vehicle.shooter === playerName ||
'LIGHT' && VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; (vehicle.additionalShooter && vehicle.additionalShooter.indexOf(playerName)) > -1) {
switch (vehicle.vehicleClass) {
stats.players[i]['vehicleHeavy'] = stats.vehicles.filter( case 'LIGHT':
(vehicle) => (vehicle.shooter === playerName || stats.players[i].vehicleLight++;
(vehicle.additionalShooter && vehicle.additionalShooter.indexOf(playerName)) > -1) && vehicle.vehicleClass === break;
'HEAVY' && VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; case 'HEAVY':
stats.players[i].vehicleHeavy++;
stats.players[i]['vehicleAir'] = stats.vehicles.filter( break;
(vehicle) => (vehicle.shooter === playerName || case 'AIR':
(vehicle.additionalShooter && vehicle.additionalShooter.indexOf(playerName)) > -1) && vehicle.vehicleClass === stats.players[i].vehicleAir++;
'AIR' && VEHICLE_BLACKLIST.indexOf(vehicle.target) < 0).length; break;
case 'BOAT':
stats.players[i].vehicleBoat++;
break;
}
}
});
stats.players[i]['friendlyFire'] = stats.kills.filter( stats.players[i]['friendlyFire'] = stats.kills.filter(
(kill) => kill.shooter === playerName && kill.friendlyFire).length; (kill) => kill.shooter === playerName && kill.friendlyFire).length;