Save vehicles and magazine on kill log (CC-36)
parent
026a3611a6
commit
07a6822920
|
@ -43,6 +43,9 @@
|
|||
+ `BLUFOR`
|
||||
+ `OPFOR`
|
||||
+ `NONE`
|
||||
+ shooterVehicle: `FV-720 Mora` (string, optional) - vehicle in whiock the shooting player sat
|
||||
+ targetVehicle: `Ifrit-GMG` (string, optional) - vehicle in which the target player sat
|
||||
+ magazine: `30 mm APFSDS` (string, optional) - magazine name used to execute the kill
|
||||
|
||||
#LogRespawn (Log)
|
||||
## Properties
|
||||
|
@ -84,3 +87,5 @@
|
|||
+ `HEAVY`
|
||||
+ `AIR`
|
||||
+ `UNKNOWN`
|
||||
+ 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
|
||||
|
|
|
@ -24,6 +24,15 @@ const LogKillSchema = new Schema({
|
|||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
magazine: {
|
||||
type: String,
|
||||
},
|
||||
shooterVehicle: {
|
||||
type: String,
|
||||
},
|
||||
targetVehicle: {
|
||||
type: String,
|
||||
},
|
||||
fraction: {
|
||||
type: String,
|
||||
enum: ['BLUFOR', 'OPFOR', 'NONE'],
|
||||
|
|
|
@ -33,6 +33,12 @@ const LogVehicleKillSchema = new Schema({
|
|||
enum: ['LIGHT', 'HEAVY', 'AIR', 'UNKNOWN'],
|
||||
required: true,
|
||||
},
|
||||
magazine: {
|
||||
type: String,
|
||||
},
|
||||
shooterVehicle: {
|
||||
type: String,
|
||||
},
|
||||
}, {
|
||||
collection: 'logVehicle',
|
||||
});
|
||||
|
|
|
@ -17,9 +17,9 @@ const vehicleNameEndRegex = /\s\(\w+:/;
|
|||
|
||||
const sideRegex = /(side:\s(.*?)\))/;
|
||||
|
||||
// const magazineRegex = /(magazine:\s(.*?)\))/;
|
||||
const magazineRegex = /(magazine:\s(.*?)\))/;
|
||||
|
||||
// const vehicleRegex = /(vehicle:\s(.*?)\))/;
|
||||
const vehicleRegex = /(vehicle:\s(.*?)\))/;
|
||||
|
||||
const categoryRegex = /(category:\s(.*?)\))/;
|
||||
|
||||
|
@ -51,7 +51,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
];
|
||||
|
||||
const addPlayerIfNotExists = (inputPlayer, steamUUID) => {
|
||||
const player = getPlayerAndFractionFromString(inputPlayer);
|
||||
const player = getPlayerInfoFromString(inputPlayer);
|
||||
if (player && player.name && player.fraction && !playerArrayContains(stats.players, player)) {
|
||||
player['warId'] = war._id;
|
||||
player['steamUUID'] = steamUUID;
|
||||
|
@ -74,7 +74,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
stats.clean.push(line);
|
||||
|
||||
const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.search(/$/) - 1);
|
||||
const shooter = getPlayerAndFractionFromString(shooterString);
|
||||
const shooter = getPlayerInfoFromString(shooterString);
|
||||
|
||||
if (line.includes('Fahrzeug:')) {
|
||||
const targetString = line.substring(line.lastIndexOf(' --- Fahrzeug: ') + 15, line.lastIndexOf(' von:'));
|
||||
|
@ -93,19 +93,36 @@ const parseWarLog = (lineArray, war) => {
|
|||
} else {
|
||||
vehicleKill.shooter = shooter ? shooter.name : null;
|
||||
}
|
||||
if (shooter.magazine) {
|
||||
vehicleKill.magazine = shooter.magazine;
|
||||
}
|
||||
if (shooter.vehicle) {
|
||||
vehicleKill.shooterVehicle = shooter.vehicle;
|
||||
}
|
||||
|
||||
stats.vehicles.push(vehicleKill);
|
||||
}
|
||||
} else {
|
||||
const targetString = line.substring(line.lastIndexOf(' --- Einheit: ') + 14, line.lastIndexOf(' von:'));
|
||||
const target = getPlayerAndFractionFromString(targetString);
|
||||
stats.kills.push({
|
||||
const target = getPlayerInfoFromString(targetString);
|
||||
const kill = {
|
||||
war: war._id,
|
||||
time: getFullTimeDate(war.date, line.split(WHITESPACE)[5]),
|
||||
shooter: shooter ? shooter.name : null,
|
||||
target: target ? target.name : null,
|
||||
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
|
||||
fraction: shooter ? shooter.fraction : 'NONE',
|
||||
});
|
||||
};
|
||||
if (shooter.magazine) {
|
||||
kill.magazine = shooter.magazine;
|
||||
}
|
||||
if (shooter.vehicle) {
|
||||
kill.shooterVehicle = shooter.vehicle;
|
||||
}
|
||||
if (target.vehicle) {
|
||||
kill.targetVehicle = target.vehicle;
|
||||
}
|
||||
stats.kills.push(kill);
|
||||
}
|
||||
} else if (line.includes('(Budget)')) {
|
||||
/**
|
||||
|
@ -173,9 +190,9 @@ const parseWarLog = (lineArray, war) => {
|
|||
const stabilized = !!line.includes('stabilisiert."');
|
||||
const medicName = line.substring(line.lastIndexOf('wurde von ') + 10,
|
||||
line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt'));
|
||||
const medic = getPlayerAndFractionFromString(medicName);
|
||||
const medic = getPlayerInfoFromString(medicName);
|
||||
const patientName = line.substring(line.lastIndexOf('--- ') + 4, line.lastIndexOf(' wurde von'));
|
||||
const patient = getPlayerAndFractionFromString(patientName);
|
||||
const patient = getPlayerInfoFromString(patientName);
|
||||
|
||||
stats.revive.push({
|
||||
war: war._id,
|
||||
|
@ -191,9 +208,9 @@ const parseWarLog = (lineArray, war) => {
|
|||
*/
|
||||
stats.clean.push(line);
|
||||
const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen'));
|
||||
const driver = getPlayerAndFractionFromString(driverString);
|
||||
const driver = getPlayerInfoFromString(driverString);
|
||||
const passengerString = line.substring(line.lastIndexOf('--- ') + 3, line.lastIndexOf(' wurde von'));
|
||||
const passenger = getPlayerAndFractionFromString(passengerString);
|
||||
const passenger = getPlayerInfoFromString(passengerString);
|
||||
const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1));
|
||||
|
||||
stats.transport.push({
|
||||
|
@ -285,15 +302,20 @@ const getBudgetEntry = (budg, warId, warDate) => {
|
|||
};
|
||||
};
|
||||
|
||||
const getPlayerAndFractionFromString = (inputString) => {
|
||||
const getPlayerInfoFromString = (inputString) => {
|
||||
const resPlayer = {};
|
||||
const playerNameRegexMatch = playerNameRegex.exec(inputString);
|
||||
const sideMatch = sideRegex.exec(inputString);
|
||||
|
||||
// SINGLE PLAYER NAME
|
||||
let name;
|
||||
if (playerNameRegexMatch && playerNameRegexMatch.length >= 2) {
|
||||
// NAME
|
||||
name = playerNameRegexMatch[2].trim();
|
||||
// do not return player for 'Error: No unit'
|
||||
if (!name && name === 'Error: No unit') {
|
||||
return;
|
||||
}
|
||||
resPlayer.name = name;
|
||||
}
|
||||
// ADDITIONAL PLAYER NAMES
|
||||
let additionalPlayerMatch;
|
||||
|
@ -317,34 +339,31 @@ const getPlayerAndFractionFromString = (inputString) => {
|
|||
}
|
||||
}
|
||||
|
||||
// const magazineMatch = magazineRegex.exec(inputString);
|
||||
// const vehicleMatch = vehicleRegex.exec(inputString);
|
||||
if (side && side !== 'ENEMY') {
|
||||
resPlayer.fraction = side === 'WEST' ? 'BLUFOR' : 'OPFOR';
|
||||
}
|
||||
|
||||
// if (magazineMatch && magazineMatch.length >= 3) {
|
||||
// MAGAZINE
|
||||
// console.log(magazineMatch[2])
|
||||
// }
|
||||
const magazineMatch = magazineRegex.exec(inputString);
|
||||
if (magazineMatch && magazineMatch.length >= 3) {
|
||||
let magazine = magazineMatch[2];
|
||||
if (new RegExp('\\(.*$').test(magazine)) {
|
||||
magazine = magazine.concat(')');
|
||||
}
|
||||
resPlayer.magazine = magazine;
|
||||
}
|
||||
|
||||
// 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' :
|
||||
undefined;
|
||||
const vehicleMatch = vehicleRegex.exec(inputString);
|
||||
if (vehicleMatch && vehicleMatch.length >= 3 && vehicleMatch[2]) {
|
||||
let vehicle = vehicleMatch[2];
|
||||
if (new RegExp('\\(.*$').test(vehicle)) {
|
||||
vehicle = vehicle.concat(')');
|
||||
}
|
||||
resPlayer.vehicle = vehicle;
|
||||
}
|
||||
|
||||
// do not return player for 'Error: No unit'
|
||||
if (name && name !== 'Error: No unit') {
|
||||
return {name: name, fraction: fraction};
|
||||
}
|
||||
return resPlayer;
|
||||
};
|
||||
|
||||
const getVehicleAndFractionFromString = (nameClassFractionString) => {
|
||||
|
|
Loading…
Reference in New Issue