Fix log parser (partially) & optimize design army overview
parent
cf7260a06d
commit
9dbef87dac
|
@ -36,18 +36,18 @@ const parseWarLog = (lineArray, war) => {
|
||||||
/**
|
/**
|
||||||
* KILLS
|
* KILLS
|
||||||
*/
|
*/
|
||||||
if (line.includes('Abschuss') && !line.includes('Fahrzeug')) {
|
if (line.includes('(Abschuss)') && !line.includes('Fahrzeug')) {
|
||||||
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('."'));
|
||||||
const shooter = getPlayerAndFractionFromString(shooterString);
|
const shooter = getPlayerAndFractionFromString(shooterString);
|
||||||
const targetString = line.substring(line.lastIndexOf(' || ') + 4, line.lastIndexOf(' von:'));
|
const targetString = line.substring(line.lastIndexOf(' --- ') + 5, line.lastIndexOf(' von:'));
|
||||||
const target = getPlayerAndFractionFromString(targetString);
|
const target = getPlayerAndFractionFromString(targetString);
|
||||||
|
|
||||||
stats.kills.push({
|
stats.kills.push({
|
||||||
war: war._id,
|
war: war._id,
|
||||||
time: getFullTimeDate(war.date, line.split(' ')[5]),
|
time: getFullTimeDate(war.date, line.split(' ')[5]),
|
||||||
shooter: shooter ? shooter.name : null,
|
shooter: shooter ? shooter.name : null,
|
||||||
target: target.name,
|
target: target ? target.name : null,
|
||||||
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
|
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
|
||||||
fraction: shooter ? shooter.fraction : 'NONE'
|
fraction: shooter ? shooter.fraction : 'NONE'
|
||||||
});
|
});
|
||||||
|
@ -56,17 +56,17 @@ const parseWarLog = (lineArray, war) => {
|
||||||
/**
|
/**
|
||||||
* BUDGET
|
* BUDGET
|
||||||
*/
|
*/
|
||||||
else if (line.includes('Budget')) {
|
else if (line.includes('(Budget)')) {
|
||||||
stats.clean.push(line);
|
stats.clean.push(line);
|
||||||
const budg = line.split(' ');
|
const budg = line.split(' ');
|
||||||
if (line.includes('Startbudget')) {
|
if (line.includes('Startbudget')) {
|
||||||
stats.war['budgetBlufor'] = transformMoneyString(budg[11]);
|
stats.war['budgetBlufor'] = transformMoneyString(budg[9]);
|
||||||
stats.war['budgetOpfor'] = transformMoneyString(budg[14]);
|
stats.war['budgetOpfor'] = transformMoneyString(budg[12].slice(0,-1));
|
||||||
// this date needs to be assigned in first place !important
|
// this date needs to be assigned in first place !important
|
||||||
stats.war.date = new Date(budg[0].substr(0, budg[0].length - 1).split('/').join('-'));
|
stats.war.date = new Date(budg[0].slice(0,-1).split('/').join('-'));
|
||||||
} else if (line.includes('Endbudget')) {
|
} else if (line.includes('Endbudget')) {
|
||||||
stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]);
|
stats.war['endBudgetBlufor'] = transformMoneyString(budg[9].substr(1));
|
||||||
stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]);
|
stats.war['endBudgetOpfor'] = transformMoneyString(budg[12].slice(0,-1));
|
||||||
stats.war.endDate = getFullTimeDate(war.date, budg[5]);
|
stats.war.endDate = getFullTimeDate(war.date, budg[5]);
|
||||||
} else {
|
} else {
|
||||||
stats.budget.push(getBudgetEntry(budg, war._id, war.date));
|
stats.budget.push(getBudgetEntry(budg, war._id, war.date));
|
||||||
|
@ -76,9 +76,9 @@ const parseWarLog = (lineArray, war) => {
|
||||||
/**
|
/**
|
||||||
* FLAG
|
* FLAG
|
||||||
*/
|
*/
|
||||||
else if (line.includes('Fahne')) {
|
else if (line.includes('(Fahne)') && !line.includes('Dominator')) {
|
||||||
stats.clean.push(line);
|
stats.clean.push(line);
|
||||||
const playerName = line.substring(line.lastIndexOf('t von ') + 6, line.lastIndexOf(' :OPT LOG END'));
|
const playerName = line.substring(line.lastIndexOf('rt von ') + 7).slice(0, -2);
|
||||||
const flagFraction = line.includes('NATO Flagge') ? 'BLUFOR' : 'OPFOR';
|
const flagFraction = line.includes('NATO Flagge') ? 'BLUFOR' : 'OPFOR';
|
||||||
const capture = !!line.includes('Flagge erobert');
|
const capture = !!line.includes('Flagge erobert');
|
||||||
|
|
||||||
|
@ -94,40 +94,40 @@ const parseWarLog = (lineArray, war) => {
|
||||||
/**
|
/**
|
||||||
* POINTS
|
* POINTS
|
||||||
*/
|
*/
|
||||||
else if (line.includes('Punkte')) {
|
else if (line.includes('(Punkte)')) {
|
||||||
stats.clean.push(line);
|
stats.clean.push(line);
|
||||||
const pt = line.split(' ');
|
const pt = line.split(' ');
|
||||||
|
|
||||||
if (line.includes('Endpunktestand')) {
|
if (line.includes('Endpunktestand')) {
|
||||||
stats.war['ptBlufor'] = parseInt(pt[11]);
|
stats.war['ptBlufor'] = parseInt(pt[9]);
|
||||||
stats.war['ptOpfor'] = parseInt(pt[14].slice(0, -1));
|
stats.war['ptOpfor'] = parseInt(pt[12].slice(0, -1));
|
||||||
// EXIT LOOP
|
// EXIT LOOP
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
stats.points.push(getPointsEntry(pt, line, war._id, war.date))
|
stats.points.push(getPointsEntry(pt, line, war._id, war.date))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* RESPAWN
|
// * RESPAWN
|
||||||
*/
|
// */
|
||||||
else if (line.includes('Respawn')) {
|
// else if (line.includes('Respawn')) {
|
||||||
stats.clean.push(line);
|
// stats.clean.push(line);
|
||||||
const resp = line.split(' ');
|
// const resp = line.split(' ');
|
||||||
const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('-') - 1);
|
// const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('-') - 1);
|
||||||
stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date));
|
// stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date));
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* REVIVE
|
* REVIVE
|
||||||
*/
|
*/
|
||||||
else if (line.includes('Revive')) {
|
else 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('--- ') + 4, line.lastIndexOf(' wurde von'));
|
||||||
const patient = getPlayerAndFractionFromString(patientName);
|
const patient = getPlayerAndFractionFromString(patientName);
|
||||||
|
|
||||||
stats.revive.push({
|
stats.revive.push({
|
||||||
|
@ -140,32 +140,32 @@ const parseWarLog = (lineArray, war) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* TRANSPORT
|
// * TRANSPORT
|
||||||
*/
|
// */
|
||||||
else if (line.includes('Transport ||')) {
|
// else if (line.includes('Transport ||')) {
|
||||||
stats.clean.push(line);
|
// stats.clean.push(line);
|
||||||
const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen'));
|
// const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen'));
|
||||||
const driver = getPlayerAndFractionFromString(driverString);
|
// const driver = getPlayerAndFractionFromString(driverString);
|
||||||
const passengerString = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von'));
|
// const passengerString = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von'));
|
||||||
const passenger = getPlayerAndFractionFromString(passengerString);
|
// const passenger = getPlayerAndFractionFromString(passengerString);
|
||||||
const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1));
|
// const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1));
|
||||||
|
//
|
||||||
stats.transport.push({
|
// stats.transport.push({
|
||||||
war: war._id,
|
// war: war._id,
|
||||||
time: getFullTimeDate(war.date, line.split(' ')[5]),
|
// time: getFullTimeDate(war.date, line.split(' ')[5]),
|
||||||
driver: driver.name,
|
// driver: driver.name,
|
||||||
passenger: passenger ? passenger.name : null,
|
// passenger: passenger ? passenger.name : null,
|
||||||
fraction: driver.fraction,
|
// fraction: driver.fraction,
|
||||||
distance: distance
|
// distance: distance
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PLAYERS
|
* PLAYERS
|
||||||
*/
|
*/
|
||||||
else if (line.includes('Fraktionsübersicht ||')) {
|
else if (line.includes('(Fraktionsuebersicht)')) {
|
||||||
const playerString = line.substring(line.lastIndexOf('Fraktionsübersicht || ') + 22, line.lastIndexOf(', PUID'));
|
const playerString = line.substring(line.lastIndexOf('--- ') + 4, line.lastIndexOf(', PUID'));
|
||||||
addPlayerIfNotExists(playerString)
|
addPlayerIfNotExists(playerString)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -200,9 +200,9 @@ const getPointsEntry = (pt, line, warId, warDate) => {
|
||||||
return {
|
return {
|
||||||
war: warId,
|
war: warId,
|
||||||
time: getFullTimeDate(warDate, pt[5]),
|
time: getFullTimeDate(warDate, pt[5]),
|
||||||
ptBlufor: parseInt(pt[12]),
|
ptBlufor: parseInt(pt[10]),
|
||||||
ptOpfor: parseInt(pt[15].slice(0, -1)),
|
ptOpfor: parseInt(pt[13].slice(0, -3)),
|
||||||
fraction: line.includes('no Domination') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
|
fraction: line.includes('Kein Dominator') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -210,9 +210,9 @@ const getBudgetEntry = (budg, warId, warDate) => {
|
||||||
return {
|
return {
|
||||||
war: warId,
|
war: warId,
|
||||||
time: getFullTimeDate(warDate, budg[5]),
|
time: getFullTimeDate(warDate, budg[5]),
|
||||||
fraction: budg[9] === 'NATO' ? 'BLUFOR' : 'OPFOR',
|
fraction: budg[7] === 'NATO' ? 'BLUFOR' : 'OPFOR',
|
||||||
oldBudget: transformMoneyString(budg[11]),
|
oldBudget: transformMoneyString(budg[9]),
|
||||||
newBudget: transformMoneyString(budg[14])
|
newBudget: transformMoneyString(budg[12])
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tbody {
|
||||||
|
background: #ffffffe0;
|
||||||
|
}
|
||||||
|
|
||||||
.cell-outline {
|
.cell-outline {
|
||||||
outline: 1px solid #D4D4D4;
|
outline: 1px solid #D4D4D4;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Component} from "@angular/core";
|
import {Component, Inject} from "@angular/core";
|
||||||
import {Award, User} from "../models/model-interfaces";
|
import {Award, User} from "../models/model-interfaces";
|
||||||
import {ActivatedRoute, Router} from "@angular/router";
|
import {ActivatedRoute, Router} from "@angular/router";
|
||||||
import {UserService} from "../services/army-management/user.service";
|
import {UserService} from "../services/army-management/user.service";
|
||||||
|
@ -6,6 +6,7 @@ import {Subscription} from "rxjs/Subscription";
|
||||||
import {RouteConfig} from "../app.config";
|
import {RouteConfig} from "../app.config";
|
||||||
import {AwardingService} from "../services/army-management/awarding.service";
|
import {AwardingService} from "../services/army-management/awarding.service";
|
||||||
import {Fraction} from "../utils/fraction.enum";
|
import {Fraction} from "../utils/fraction.enum";
|
||||||
|
import {DOCUMENT} from "@angular/common";
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -30,10 +31,19 @@ export class ArmyMemberComponent {
|
||||||
constructor(private router: Router,
|
constructor(private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private awardingService: AwardingService) {
|
private awardingService: AwardingService,
|
||||||
|
@Inject(DOCUMENT) private document) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
// set background image css
|
||||||
|
const backgroundCss = ' background-image: url(../assets/bg.jpg);\n' +
|
||||||
|
' background-size: cover;\n' +
|
||||||
|
' background-attachment: fixed;\n' +
|
||||||
|
' background-position: center;\n' +
|
||||||
|
' background-repeat: no-repeat;';
|
||||||
|
this.document.getElementById('right').setAttribute('style', backgroundCss);
|
||||||
|
|
||||||
this.subscription = this.route.params
|
this.subscription = this.route.params
|
||||||
.map(params => params['id'])
|
.map(params => params['id'])
|
||||||
.filter(id => id != undefined)
|
.filter(id => id != undefined)
|
||||||
|
@ -48,6 +58,10 @@ export class ArmyMemberComponent {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.document.getElementById('right').setAttribute('style', '');
|
||||||
|
}
|
||||||
|
|
||||||
backToOverview() {
|
backToOverview() {
|
||||||
this.router.navigate([RouteConfig.overviewPath]);
|
this.router.navigate([RouteConfig.overviewPath]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,3 +63,13 @@ img {
|
||||||
text-align: center
|
text-align: center
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.member-count {
|
||||||
|
margin-top: 15px;
|
||||||
|
padding: 8px;
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
|
color: whitesmoke;
|
||||||
|
background: #222222;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="padding: 20px; text-align: center;">Armeemitglieder: {{army.BLUFOR.memberCount}}</div>
|
<div class="member-count">Armeemitglieder: {{army.BLUFOR.memberCount}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pull-right" style="width: 45%;">
|
<div class="pull-right" style="width: 45%;">
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="padding: 20px; text-align: center;">Armeemitglieder: {{army.OPFOR.memberCount}}</div>
|
<div class="member-count">Armeemitglieder: {{army.OPFOR.memberCount}}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 968 KiB After Width: | Height: | Size: 654 KiB |
Loading…
Reference in New Issue