diff --git a/api/tools/log-parse-tool.js b/api/tools/log-parse-tool.js index 3a3c429..6c6473c 100644 --- a/api/tools/log-parse-tool.js +++ b/api/tools/log-parse-tool.js @@ -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]) } }; diff --git a/package.json b/package.json index 008f884..c014a4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opt-cc", - "version": "1.6.7", + "version": "1.6.8", "license": "MIT", "author": "Florian Hartwich ", "private": true, diff --git a/static/src/app/app.component.ts b/static/src/app/app.component.ts index 21105b0..9df1f2f 100644 --- a/static/src/app/app.component.ts +++ b/static/src/app/app.component.ts @@ -30,7 +30,7 @@ export class AppComponent { } if (event instanceof NavigationEnd) { this.loading = false; - if (router.url.includes('overview')) { + if (router.url.includes(RouteConfig.overviewPath)) { window.scrollTo({left: 0, top: 0, behavior: 'smooth'}); } } diff --git a/static/src/app/army/army-member.component.css b/static/src/app/army/army-member.component.css index 3f5b1b9..81b6206 100644 --- a/static/src/app/army/army-member.component.css +++ b/static/src/app/army/army-member.component.css @@ -32,6 +32,10 @@ color: white; } +tbody { + background: #ffffffe0; +} + .cell-outline { outline: 1px solid #D4D4D4; } diff --git a/static/src/app/army/army-member.component.ts b/static/src/app/army/army-member.component.ts index 6ecc23b..19b0f7b 100644 --- a/static/src/app/army/army-member.component.ts +++ b/static/src/app/army/army-member.component.ts @@ -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,8 @@ 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"; +import {CSSHelpers} from "../global.helpers"; @Component({ @@ -30,10 +32,14 @@ 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 + this.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg')); + this.subscription = this.route.params .map(params => params['id']) .filter(id => id != undefined) @@ -48,6 +54,12 @@ export class ArmyMemberComponent { }; + ngOnDestroy() { + if (this.router.url !== '/' + RouteConfig.overviewPath) { + this.document.getElementById('right').setAttribute('style', ''); + } + } + backToOverview() { this.router.navigate([RouteConfig.overviewPath]); } diff --git a/static/src/app/army/army.component.css b/static/src/app/army/army.component.css index 4d9c552..ba5a69f 100644 --- a/static/src/app/army/army.component.css +++ b/static/src/app/army/army.component.css @@ -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; +} + diff --git a/static/src/app/army/army.component.html b/static/src/app/army/army.component.html index 4d62234..1baffa1 100644 --- a/static/src/app/army/army.component.html +++ b/static/src/app/army/army.component.html @@ -27,7 +27,7 @@ -
Armeemitglieder: {{army.BLUFOR.memberCount}}
+
Armeemitglieder: {{army.BLUFOR.memberCount}}
@@ -56,7 +56,7 @@
-
Armeemitglieder: {{army.OPFOR.memberCount}}
+
Armeemitglieder: {{army.OPFOR.memberCount}}
diff --git a/static/src/app/army/army.component.ts b/static/src/app/army/army.component.ts index a7e100f..069b6d2 100644 --- a/static/src/app/army/army.component.ts +++ b/static/src/app/army/army.component.ts @@ -4,6 +4,8 @@ import {ArmyService} from "../services/army-service/army.service"; import {ActivatedRoute, Router} from "@angular/router"; import {Fraction} from "../utils/fraction.enum"; import {DOCUMENT} from "@angular/common"; +import {RouteConfig} from "../app.config"; +import {CSSHelpers} from "../global.helpers"; @Component({ @@ -25,12 +27,7 @@ export class ArmyComponent { 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.document.getElementById('right').setAttribute('style', CSSHelpers.getBackgroundCSS('../assets/bg.jpg')); // init army data this.armyService.getArmy() @@ -40,7 +37,9 @@ export class ArmyComponent { }; ngOnDestroy() { - this.document.getElementById('right').setAttribute('style', ''); + if (this.router.url.includes(RouteConfig.overviewPath)) { + this.document.getElementById('right').setAttribute('style', ''); + } } select(memberId) { diff --git a/static/src/app/global.helpers.ts b/static/src/app/global.helpers.ts new file mode 100644 index 0000000..4bd3346 --- /dev/null +++ b/static/src/app/global.helpers.ts @@ -0,0 +1,9 @@ +export const CSSHelpers = { + getBackgroundCSS: (imageUrl) => { + return 'background-image: url(' + imageUrl + ');' + + 'background-size: cover;' + + 'background-attachment: fixed;' + + 'background-position: center;' + + 'background-repeat: no-repeat;'; + } +}; diff --git a/static/src/assets/bg.jpg b/static/src/assets/bg.jpg index 7a560c0..73d703a 100644 Binary files a/static/src/assets/bg.jpg and b/static/src/assets/bg.jpg differ