Add model fields and correct enum usage for vehicle class
parent
b927d48b86
commit
9d6c6e01b3
|
@ -25,6 +25,11 @@ const LogVehicleKillSchema = new Schema({
|
|||
enum: ['BLUFOR', 'OPFOR', 'NONE'],
|
||||
required: true,
|
||||
},
|
||||
vehicleClass: {
|
||||
type: String,
|
||||
enum: ['LIGHT', 'HEAVY', 'AIR', "UNKNOWN"],
|
||||
required: true,
|
||||
},
|
||||
}, {
|
||||
collection: 'logVehicle',
|
||||
});
|
||||
|
|
|
@ -24,7 +24,19 @@ const PlayerSchema = new Schema({
|
|||
set: (v) => Math.round(v),
|
||||
required: true,
|
||||
},
|
||||
vehicle: {
|
||||
vehicleLight: {
|
||||
type: Number,
|
||||
get: (v) => Math.round(v),
|
||||
set: (v) => Math.round(v),
|
||||
required: true,
|
||||
},
|
||||
vehicleHeavy: {
|
||||
type: Number,
|
||||
get: (v) => Math.round(v),
|
||||
set: (v) => Math.round(v),
|
||||
required: true,
|
||||
},
|
||||
vehicleAir: {
|
||||
type: Number,
|
||||
get: (v) => Math.round(v),
|
||||
set: (v) => Math.round(v),
|
||||
|
|
|
@ -6,7 +6,7 @@ const WHITESPACE = ' ';
|
|||
|
||||
const VehicleClasses = Object.freeze({
|
||||
LIGHT: "Leicht",
|
||||
HEAVY: "Leicht",
|
||||
HEAVY: "Schwer",
|
||||
AIR: "Flug",
|
||||
UNKNOWN: "Unbekannt"
|
||||
});
|
||||
|
@ -74,6 +74,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
shooter: shooter ? shooter.name : null,
|
||||
target: target ? target.name : null,
|
||||
fraction: shooter ? shooter.fraction : 'NONE',
|
||||
vehicleClass: target.vehicleClass,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
|
@ -262,18 +263,29 @@ const getVehicleAndFractionFromString = (nameClassFractionString) => {
|
|||
|
||||
const vehicleFraction = nameArray[nameArray.length - 1];
|
||||
nameArray.pop();
|
||||
const vehicleClass = nameArray[nameArray.length - 1].replace('(', '').replace(')', '');
|
||||
const veheicleClassString = nameArray[nameArray.length - 1].replace('(', '').replace(')', '');
|
||||
nameArray.pop();
|
||||
const vehicleName = nameArray.join(WHITESPACE);
|
||||
|
||||
// nno counting here - is some basic fraction equipment identifier (i.e. parachute)
|
||||
if (vehicleFraction === 'OPF_F' || vehicleFraction === 'BLU_F' || vehicleClass === VehicleClasses.UNKNOWN) {
|
||||
// skip logging here - this is some basic equipment identifier (i.e. parachute)
|
||||
if (vehicleFraction === 'OPF_F' || vehicleFraction === 'BLU_F' || veheicleClassString === VehicleClasses.UNKNOWN) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fraction = vehicleFraction === '(OPT_NATO)' || vehicleFraction === '(OPT_NATO_T)' ? 'BLUFOR' : 'OPFOR';
|
||||
|
||||
return {name: vehicleName, fraction: fraction, class: vehicleClass};
|
||||
let vehicleClass;
|
||||
for (const key in VehicleClasses) {
|
||||
if (VehicleClasses.hasOwnProperty(key) && VehicleClasses[key] === veheicleClassString) {
|
||||
vehicleClass = key;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
name: vehicleName,
|
||||
fraction: fraction,
|
||||
vehicleClass: vehicleClass,
|
||||
};
|
||||
};
|
||||
|
||||
const transformMoneyString = (budgetString) => {
|
||||
|
|
Loading…
Reference in New Issue