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