Compare commits
No commits in common. "91ebda52b01284830e9e1b40014d102abeb79bb9" and "35f6ac04b3455fa82aa8a2d149d6ccf02294e6f1" have entirely different histories.
91ebda52b0
...
35f6ac04b3
|
@ -63,31 +63,25 @@ wars.route('/')
|
||||||
})
|
})
|
||||||
|
|
||||||
.post(apiAuthenticationMiddleware, checkMT, upload.single('log'), (req, res, next) => {
|
.post(apiAuthenticationMiddleware, checkMT, upload.single('log'), (req, res, next) => {
|
||||||
const body = req.body;
|
let body = req.body;
|
||||||
const warBody = new WarModel(body);
|
const bodyWar = new WarModel(body);
|
||||||
|
|
||||||
if (req.file) {
|
if (req.file) {
|
||||||
|
// bodyWar.save((err, war) => {
|
||||||
|
// if (err) {
|
||||||
|
// return next(err);
|
||||||
|
// }
|
||||||
fs.readFile(req.file.buffer, (file, err) => {
|
fs.readFile(req.file.buffer, (file, err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const lineArray = file.toString().split("\n");
|
const lineArray = file.toString().split("\n");
|
||||||
const statsResult = parseWarLog(lineArray, warBody);
|
res.locals.items = parseWarLog(lineArray, bodyWar);
|
||||||
statsResult.war.save((err, war) => {
|
res.locals.processed = true;
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
PlayerModel.create(statsResult.players, function (err) {
|
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
res.status(codes.created);
|
|
||||||
res.locals.items = war;
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
})
|
// })
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
const err = new Error('no Logfile provided');
|
const err = new Error('no Logfile provided');
|
||||||
err.status = codes.wrongmediasend;
|
err.status = codes.wrongmediasend;
|
||||||
|
|
|
@ -18,7 +18,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
|
|
||||||
const addPlayersIfNotExists = (inputPlayers) => {
|
const addPlayersIfNotExists = (inputPlayers) => {
|
||||||
inputPlayers.forEach(player => {
|
inputPlayers.forEach(player => {
|
||||||
if (player && player.name && player.fraction && !arrayContains(stats.players, player)) {
|
if (player && !arrayContains(stats.players, player)) {
|
||||||
player['warId'] = war._id;
|
player['warId'] = war._id;
|
||||||
stats.players.push(player);
|
stats.players.push(player);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
stats.clean.push(line);
|
stats.clean.push(line);
|
||||||
const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.lastIndexOf('. :OPT LOG END'));
|
const shooterString = line.substring(line.lastIndexOf(' von: ') + 6, line.lastIndexOf('. :OPT LOG END'));
|
||||||
const shooter = getPlayerAndFractionFromString(shooterString);
|
const shooter = getPlayerAndFractionFromString(shooterString);
|
||||||
|
|
||||||
const targetString = line.substring(line.lastIndexOf(' || ') + 4, line.lastIndexOf(' von:'));
|
const targetString = line.substring(line.lastIndexOf(' || ') + 4, line.lastIndexOf(' von:'));
|
||||||
const target = getPlayerAndFractionFromString(targetString);
|
const target = getPlayerAndFractionFromString(targetString);
|
||||||
|
|
||||||
|
@ -57,7 +58,6 @@ const parseWarLog = (lineArray, war) => {
|
||||||
stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]);
|
stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]);
|
||||||
stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]);
|
stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]);
|
||||||
} else if (line.includes('Startbudget')) {
|
} else if (line.includes('Startbudget')) {
|
||||||
stats.war.date = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-') + 'T22:00:00.000+02:00');
|
|
||||||
stats.war['budgetBlufor'] = transformMoneyString(budg[11]);
|
stats.war['budgetBlufor'] = transformMoneyString(budg[11]);
|
||||||
stats.war['budgetOpfor'] = transformMoneyString(budg[14]);
|
stats.war['budgetOpfor'] = transformMoneyString(budg[14]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,8 +114,7 @@ const parseWarLog = (lineArray, war) => {
|
||||||
if (line.includes('Revive')) {
|
if (line.includes('Revive')) {
|
||||||
stats.clean.push(line);
|
stats.clean.push(line);
|
||||||
const stabilized = !!line.includes('stabilisiert');
|
const stabilized = !!line.includes('stabilisiert');
|
||||||
const medicName = line.substring(line.lastIndexOf('wurde von ') + 10,
|
const medicName = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt'));
|
||||||
line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt'));
|
|
||||||
const medic = getPlayerAndFractionFromString(medicName);
|
const medic = getPlayerAndFractionFromString(medicName);
|
||||||
const patientName = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von'));
|
const patientName = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von'));
|
||||||
const patient = getPlayerAndFractionFromString(patientName);
|
const patient = getPlayerAndFractionFromString(patientName);
|
||||||
|
@ -154,20 +153,11 @@ const parseWarLog = (lineArray, war) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < stats.players.length; i++) {
|
|
||||||
const playerName = stats.players[i].name;
|
|
||||||
stats.players[i]['respawn'] = stats.respawn.filter(res => res.player === playerName).length;
|
|
||||||
stats.players[i]['kill'] = stats.kills.filter(kill => kill.shooter === playerName && !kill.friendlyFire).length;
|
|
||||||
stats.players[i]['friendlyFire'] = stats.kills.filter(kill => kill.shooter === playerName && kill.friendlyFire).length;
|
|
||||||
stats.players[i]['death'] = stats.kills.filter(kill => kill.target === playerName).length;
|
|
||||||
stats.players[i]['revive'] = stats.revive.filter(rev => rev.medic === playerName && !rev.stabilized).length;
|
|
||||||
stats.players[i]['flagTouch'] = stats.flag.filter(flag => flag.player === playerName).length;
|
|
||||||
}
|
|
||||||
|
|
||||||
stats.war.playersBlufor = stats.players.filter(player => player.fraction === 'BLUFOR').length;
|
stats.war.playersBlufor = stats.players.filter(player => player.fraction === 'BLUFOR').length;
|
||||||
stats.war.playersOpfor = stats.players.filter(player => player.fraction === 'OPFOR').length;
|
stats.war.playersOpfor = stats.players.filter(player => player.fraction === 'OPFOR').length;
|
||||||
|
|
||||||
return stats;
|
return stats;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getRespawnEntry = (respawn, playerName, warId) => {
|
const getRespawnEntry = (respawn, playerName, warId) => {
|
||||||
|
@ -199,10 +189,10 @@ const getBudgetEntry = (budg, warId) => {
|
||||||
|
|
||||||
const getPlayerAndFractionFromString = (nameAndFractionString) => {
|
const getPlayerAndFractionFromString = (nameAndFractionString) => {
|
||||||
const nameArray = nameAndFractionString.split(' ');
|
const nameArray = nameAndFractionString.split(' ');
|
||||||
const fraction = nameArray[nameArray.length - 1] !== '(ENEMY)' ? nameArray[nameArray.length - 1] === '(WEST)' ? 'BLUFOR' : 'OPFOR' : undefined;
|
const fraction = nameArray[nameArray.length - 1] === '(WEST)' ? 'BLUFOR' : 'OPFOR';
|
||||||
const name = nameAndFractionString.substring(0, nameAndFractionString.indexOf(nameArray[nameArray.length - 1]) - 1);
|
const name = nameAndFractionString.substring(0, nameAndFractionString.indexOf(nameArray[nameArray.length - 1]) - 1);
|
||||||
// do not return player for 'Selbstverschulden'
|
// do not return player for 'Selbstverschulden'
|
||||||
if (name && name !== 'Error: No unit') {
|
if (name || name === 'Error: No unit') {
|
||||||
return {name: name, fraction: fraction};
|
return {name: name, fraction: fraction};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "opt-cc",
|
"name": "opt-cc",
|
||||||
"version": "1.6.0",
|
"version": "1.5.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -12,6 +12,36 @@
|
||||||
<show-error text="Name" path="title"></show-error>
|
<show-error text="Name" path="title"></show-error>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="date">Datum</label>
|
||||||
|
<input type="date" class="form-control"
|
||||||
|
[(ngModel)]="war.date"
|
||||||
|
name="date"
|
||||||
|
id="date"
|
||||||
|
required/>
|
||||||
|
<show-error text="Datum" path="date"></show-error>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="ptblu">Punkte NATO</label>
|
||||||
|
<input type="number" class="form-control" step="1"
|
||||||
|
[(ngModel)]="war.ptBlufor"
|
||||||
|
name="ptblu"
|
||||||
|
id="ptblu"
|
||||||
|
required/>
|
||||||
|
<show-error text="Punkte NATO" path="ptblu"></show-error>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="ptopf">Punkte CSAT</label>
|
||||||
|
<input type="number" class="form-control" step="1"
|
||||||
|
[(ngModel)]="war.ptOpfor"
|
||||||
|
name="ptopf"
|
||||||
|
id="ptopf"
|
||||||
|
required/>
|
||||||
|
<show-error text="Punkte CSAT" path="ptopf"></show-error>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="campaign">Kampagne</label>
|
<label for="campaign">Kampagne</label>
|
||||||
<select class="form-control"
|
<select class="form-control"
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {CampaignService} from "../../services/campaign-service/campaign.service"
|
||||||
})
|
})
|
||||||
export class WarSubmitComponent {
|
export class WarSubmitComponent {
|
||||||
|
|
||||||
war: War = {players: []};
|
war: War = {date: new Date().toISOString().slice(0, 10), players: []};
|
||||||
|
|
||||||
fileList: FileList;
|
fileList: FileList;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue