Add additional budget information to db enry (CC-15)
parent
d8330074d5
commit
51f9371659
|
@ -3,7 +3,6 @@
|
|||
+ _id: `` (string, required) - log entry id
|
||||
+ war: `` (string, required) - warId
|
||||
+ time: `` (string, required) - logging timestamp
|
||||
+ __v: 0 (number, required) - object version number
|
||||
|
||||
# LogPoints (Log)
|
||||
## Properties
|
||||
|
@ -74,14 +73,14 @@
|
|||
#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
|
||||
+ 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
|
||||
+ `BLUFOR`
|
||||
+ `OPFOR`
|
||||
+ `NONE`
|
||||
+ vehicleClass: `LIGHT` (enum, required) - class of shot vehicle
|
||||
+ vehicleClass: `LIGHT` (enum[string], required) - class of shot vehicle
|
||||
+ Members
|
||||
+ `LIGHT`
|
||||
+ `HEAVY`
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
const mongoose = require('mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const LogBudgetSchema = new Schema({
|
||||
const LogBudgetSchema = new Schema(
|
||||
{
|
||||
war: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: 'War',
|
||||
|
@ -30,7 +31,18 @@ const LogBudgetSchema = new Schema({
|
|||
set: (v) => Math.round(v),
|
||||
required: true,
|
||||
},
|
||||
}, {
|
||||
buy: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
},
|
||||
player: {
|
||||
type: String,
|
||||
},
|
||||
item: {
|
||||
type: String,
|
||||
}
|
||||
},
|
||||
{
|
||||
collection: 'logBudget',
|
||||
versionKey: false,
|
||||
});
|
||||
|
|
|
@ -13,6 +13,12 @@ const VehicleClasses = Object.freeze({
|
|||
|
||||
const playerNameRegex = /(^|,\s)(.*?)\s\(/g;
|
||||
|
||||
const budgetPlayerNameRegex = /\d*\.\s(.*)\s\(ver\)kaufte/;
|
||||
|
||||
const budgetItemNameRegex = /\(ver\)kaufte\s(.*)\"$/;
|
||||
|
||||
const budgetRespawnNameRegex = /Respawn\svon\s(.*)\"$/;
|
||||
|
||||
const vehicleNameEndRegex = /\s\(\w+:/;
|
||||
|
||||
const sideRegex = /(side:\s(.*?)\))/;
|
||||
|
@ -178,7 +184,7 @@ const parseWarLog = (lineArray, war) => {
|
|||
const playerName = line.substring(line.lastIndexOf('Respawn von ') + 12, line.lastIndexOf('"'));
|
||||
stats.respawn.push(getRespawnEntry(budg, playerName, war._id, war.date));
|
||||
}
|
||||
stats.budget.push(getBudgetEntry(budg, war._id, war.date));
|
||||
stats.budget.push(getBudgetEntry(line, budg, war._id, war.date));
|
||||
}
|
||||
} else if (line.includes('(Fahne)') && !line.includes('Dominator')) {
|
||||
/**
|
||||
|
@ -405,14 +411,37 @@ const getPointsEntry = (pt, line, warId, warDate) => {
|
|||
};
|
||||
};
|
||||
|
||||
const getBudgetEntry = (budg, warId, warDate) => {
|
||||
return {
|
||||
const getBudgetEntry = (line, budg, warId, warDate) => {
|
||||
const timestamp = getFullTimeDate(warDate, budg[5]);
|
||||
const oldBudget = transformMoneyString(budg[9]);
|
||||
const newBudget = transformMoneyString(budg[12]);
|
||||
const fraction = budg[7] === 'NATO' ? 'BLUFOR' : 'OPFOR';
|
||||
|
||||
const budgetEntry = {
|
||||
war: warId,
|
||||
time: getFullTimeDate(warDate, budg[5]),
|
||||
fraction: budg[7] === 'NATO' ? 'BLUFOR' : 'OPFOR',
|
||||
oldBudget: transformMoneyString(budg[9]),
|
||||
newBudget: transformMoneyString(budg[12]),
|
||||
time: timestamp,
|
||||
fraction: fraction,
|
||||
oldBudget: oldBudget,
|
||||
newBudget: newBudget,
|
||||
buy: oldBudget <= newBudget,
|
||||
};
|
||||
|
||||
const budgetRespawnMatch = budgetRespawnNameRegex.exec(line);
|
||||
if (budgetRespawnMatch && budgetRespawnMatch.length > 1) {
|
||||
budgetEntry.player = budgetRespawnMatch[1];
|
||||
budgetEntry.item = "Respawn";
|
||||
} else {
|
||||
const itemNameMatch = budgetItemNameRegex.exec(line);
|
||||
const playerNameMatch = budgetPlayerNameRegex.exec(line);
|
||||
if (playerNameMatch && playerNameMatch.length > 1) {
|
||||
budgetEntry.player = playerNameMatch[1];
|
||||
}
|
||||
if (itemNameMatch && itemNameMatch.length > 1) {
|
||||
budgetEntry.item = itemNameMatch[1];
|
||||
}
|
||||
}
|
||||
|
||||
return budgetEntry;
|
||||
};
|
||||
|
||||
const getPlayerInfoFromString = (inputString) => {
|
||||
|
|
Loading…
Reference in New Issue