Fix log parser (partially) & optimize design army overview

pull/23/head
HardiReady 2018-01-16 19:46:28 +01:00
parent cf7260a06d
commit 9dbef87dac
6 changed files with 88 additions and 60 deletions

View File

@ -36,18 +36,18 @@ const parseWarLog = (lineArray, war) => {
/**
* KILLS
*/
if (line.includes('Abschuss') && !line.includes('Fahrzeug')) {
if (line.includes('(Abschuss)') && !line.includes('Fahrzeug')) {
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 targetString = line.substring(line.lastIndexOf(' || ') + 4, line.lastIndexOf(' von:'));
const targetString = line.substring(line.lastIndexOf(' --- ') + 5, line.lastIndexOf(' von:'));
const target = getPlayerAndFractionFromString(targetString);
stats.kills.push({
war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]),
shooter: shooter ? shooter.name : null,
target: target.name,
target: target ? target.name : null,
friendlyFire: shooter ? target.fraction === shooter.fraction : false,
fraction: shooter ? shooter.fraction : 'NONE'
});
@ -56,17 +56,17 @@ const parseWarLog = (lineArray, war) => {
/**
* BUDGET
*/
else if (line.includes('Budget')) {
else if (line.includes('(Budget)')) {
stats.clean.push(line);
const budg = line.split(' ');
if (line.includes('Startbudget')) {
stats.war['budgetBlufor'] = transformMoneyString(budg[11]);
stats.war['budgetOpfor'] = transformMoneyString(budg[14]);
stats.war['budgetBlufor'] = transformMoneyString(budg[9]);
stats.war['budgetOpfor'] = transformMoneyString(budg[12].slice(0,-1));
// 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')) {
stats.war['endBudgetBlufor'] = transformMoneyString(budg[11]);
stats.war['endBudgetOpfor'] = transformMoneyString(budg[14]);
stats.war['endBudgetBlufor'] = transformMoneyString(budg[9].substr(1));
stats.war['endBudgetOpfor'] = transformMoneyString(budg[12].slice(0,-1));
stats.war.endDate = getFullTimeDate(war.date, budg[5]);
} else {
stats.budget.push(getBudgetEntry(budg, war._id, war.date));
@ -76,9 +76,9 @@ const parseWarLog = (lineArray, war) => {
/**
* FLAG
*/
else if (line.includes('Fahne')) {
else if (line.includes('(Fahne)') && !line.includes('Dominator')) {
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 capture = !!line.includes('Flagge erobert');
@ -94,40 +94,40 @@ const parseWarLog = (lineArray, war) => {
/**
* POINTS
*/
else if (line.includes('Punkte')) {
else if (line.includes('(Punkte)')) {
stats.clean.push(line);
const pt = line.split(' ');
if (line.includes('Endpunktestand')) {
stats.war['ptBlufor'] = parseInt(pt[11]);
stats.war['ptOpfor'] = parseInt(pt[14].slice(0, -1));
stats.war['ptBlufor'] = parseInt(pt[9]);
stats.war['ptOpfor'] = parseInt(pt[12].slice(0, -1));
// EXIT LOOP
return true;
} else {
stats.points.push(getPointsEntry(pt, line, war._id, war.date))
}
}
/**
* RESPAWN
*/
else if (line.includes('Respawn')) {
stats.clean.push(line);
const resp = line.split(' ');
const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('-') - 1);
stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date));
}
//
// /**
// * RESPAWN
// */
// else if (line.includes('Respawn')) {
// stats.clean.push(line);
// const resp = line.split(' ');
// const playerName = line.substring(line.lastIndexOf('Spieler:') + 9, line.lastIndexOf('-') - 1);
// stats.respawn.push(getRespawnEntry(resp, playerName, war._id, war.date));
// }
/**
* REVIVE
*/
else if (line.includes('Revive')) {
else if (line.includes('(Revive)')) {
stats.clean.push(line);
const stabilized = !!line.includes('stabilisiert');
const stabilized = !!line.includes('stabilisiert."');
const medicName = line.substring(line.lastIndexOf('wurde von ') + 10,
line.lastIndexOf(stabilized ? ' stabilisiert' : ' wiederbelebt'));
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);
stats.revive.push({
@ -140,32 +140,32 @@ const parseWarLog = (lineArray, war) => {
});
}
/**
* TRANSPORT
*/
else if (line.includes('Transport ||')) {
stats.clean.push(line);
const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen'));
const driver = getPlayerAndFractionFromString(driverString);
const passengerString = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von'));
const passenger = getPlayerAndFractionFromString(passengerString);
const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1));
stats.transport.push({
war: war._id,
time: getFullTimeDate(war.date, line.split(' ')[5]),
driver: driver.name,
passenger: passenger ? passenger.name : null,
fraction: driver.fraction,
distance: distance
});
}
// /**
// * TRANSPORT
// */
// else if (line.includes('Transport ||')) {
// stats.clean.push(line);
// const driverString = line.substring(line.lastIndexOf('wurde von ') + 10, line.lastIndexOf(' eingeflogen'));
// const driver = getPlayerAndFractionFromString(driverString);
// const passengerString = line.substring(line.lastIndexOf('|| ') + 3, line.lastIndexOf(' wurde von'));
// const passenger = getPlayerAndFractionFromString(passengerString);
// const distance = parseInt(line.substring(line.lastIndexOf('eingeflogen (') + 13, line.lastIndexOf('m)') - 1));
//
// stats.transport.push({
// war: war._id,
// time: getFullTimeDate(war.date, line.split(' ')[5]),
// driver: driver.name,
// passenger: passenger ? passenger.name : null,
// fraction: driver.fraction,
// distance: distance
// });
// }
/**
* PLAYERS
*/
else if (line.includes('Fraktionsübersicht ||')) {
const playerString = line.substring(line.lastIndexOf('Fraktionsübersicht || ') + 22, line.lastIndexOf(', PUID'));
else if (line.includes('(Fraktionsuebersicht)')) {
const playerString = line.substring(line.lastIndexOf('--- ') + 4, line.lastIndexOf(', PUID'));
addPlayerIfNotExists(playerString)
}
});
@ -200,9 +200,9 @@ const getPointsEntry = (pt, line, warId, warDate) => {
return {
war: warId,
time: getFullTimeDate(warDate, pt[5]),
ptBlufor: parseInt(pt[12]),
ptOpfor: parseInt(pt[15].slice(0, -1)),
fraction: line.includes('no Domination') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
ptBlufor: parseInt(pt[10]),
ptOpfor: parseInt(pt[13].slice(0, -3)),
fraction: line.includes('Kein Dominator') ? 'NONE' : line.includes('NATO +1') ? 'BLUFOR' : 'OPFOR'
}
};
@ -210,9 +210,9 @@ const getBudgetEntry = (budg, warId, warDate) => {
return {
war: warId,
time: getFullTimeDate(warDate, budg[5]),
fraction: budg[9] === 'NATO' ? 'BLUFOR' : 'OPFOR',
oldBudget: transformMoneyString(budg[11]),
newBudget: transformMoneyString(budg[14])
fraction: budg[7] === 'NATO' ? 'BLUFOR' : 'OPFOR',
oldBudget: transformMoneyString(budg[9]),
newBudget: transformMoneyString(budg[12])
}
};

View File

@ -32,6 +32,10 @@
color: white;
}
tbody {
background: #ffffffe0;
}
.cell-outline {
outline: 1px solid #D4D4D4;
}

View File

@ -1,4 +1,4 @@
import {Component} from "@angular/core";
import {Component, Inject} from "@angular/core";
import {Award, User} from "../models/model-interfaces";
import {ActivatedRoute, Router} from "@angular/router";
import {UserService} from "../services/army-management/user.service";
@ -6,6 +6,7 @@ import {Subscription} from "rxjs/Subscription";
import {RouteConfig} from "../app.config";
import {AwardingService} from "../services/army-management/awarding.service";
import {Fraction} from "../utils/fraction.enum";
import {DOCUMENT} from "@angular/common";
@Component({
@ -30,10 +31,19 @@ export class ArmyMemberComponent {
constructor(private router: Router,
private route: ActivatedRoute,
private userService: UserService,
private awardingService: AwardingService) {
private awardingService: AwardingService,
@Inject(DOCUMENT) private document) {
}
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
.map(params => params['id'])
.filter(id => id != undefined)
@ -48,6 +58,10 @@ export class ArmyMemberComponent {
};
ngOnDestroy() {
this.document.getElementById('right').setAttribute('style', '');
}
backToOverview() {
this.router.navigate([RouteConfig.overviewPath]);
}

View File

@ -63,3 +63,13 @@ img {
text-align: center
}
.member-count {
margin-top: 15px;
padding: 8px;
text-align: center;
font-weight: bold;
color: whitesmoke;
background: #222222;
border-radius: 12px;
}

View File

@ -27,7 +27,7 @@
</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 class="pull-right" style="width: 45%;">
@ -56,7 +56,7 @@
</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>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 968 KiB

After

Width:  |  Height:  |  Size: 654 KiB