From f4a9e4710c2d5d1b1ed35ba12a59b3cb7ac0fb98 Mon Sep 17 00:00:00 2001 From: S1mple133 Date: Wed, 26 Apr 2023 11:33:54 +0200 Subject: [PATCH 1/2] fix: fix heart columns and skin size --- frontend/src/app/auth.service.ts | 11 +++++ .../player-status.component.html | 13 ++++-- .../player-status/player-status.component.ts | 40 ++++++++++++++----- frontend/src/app/home/home.component.ts | 3 -- 4 files changed, 51 insertions(+), 16 deletions(-) diff --git a/frontend/src/app/auth.service.ts b/frontend/src/app/auth.service.ts index f5905a6..2f382ac 100644 --- a/frontend/src/app/auth.service.ts +++ b/frontend/src/app/auth.service.ts @@ -45,6 +45,17 @@ export class AuthService { return this._cookieService.get("token"); } + public getUsername() { + let token = this._cookieService.get("token"); + + if(token) { + let decodedJWT = JSON.parse(window.atob(token.split('.')[1])); + return decodedJWT.username; + } + + return '' + } + public isLoggedIn(): boolean { let token = this._cookieService.get("token"); return token != null && !this.jwtHelper.isTokenExpired(token); diff --git a/frontend/src/app/components/player-status/player-status.component.html b/frontend/src/app/components/player-status/player-status.component.html index 750db09..c071c55 100644 --- a/frontend/src/app/components/player-status/player-status.component.html +++ b/frontend/src/app/components/player-status/player-status.component.html @@ -58,11 +58,16 @@
-

S1mple133

+

{{username}}

-
- - +
+
+ + +
+
+ +
diff --git a/frontend/src/app/components/player-status/player-status.component.ts b/frontend/src/app/components/player-status/player-status.component.ts index ca68573..555f7bd 100644 --- a/frontend/src/app/components/player-status/player-status.component.ts +++ b/frontend/src/app/components/player-status/player-status.component.ts @@ -33,8 +33,13 @@ export class PlayerStatusComponent implements OnInit, OnChanges { element: "", matrik: 0 } - heartRows: number[] = [] + heartHeartsPerRowArr: number[] = [] + heartRows: number[] = []; @Input() playerName: string = ''; + username: string = ''; + heartsInLastRow: number[] = []; + + HEALTH_HEARTS_PER_ROW = 10; constructor(private _authService: AuthService, private _statsService: StatsService) { @@ -52,25 +57,42 @@ export class PlayerStatusComponent implements OnInit, OnChanges { updateData(playerName: string) { if(playerName == '') { this._statsService.getSkinName().subscribe((skin: any) => { - genSkin(skin.skin, 300, 500); + genSkin(skin.skin, 300, 350); }); this._statsService.getLatestPlayerStats().subscribe(stats => { this.latestPlayerStats = stats; - while(this.heartRows.length < stats.health) { - this.heartRows.push(0) - } + this.calculateHealthRows(this.latestPlayerStats.health); }) + + this.username = this._authService.getUsername() } else { - genSkin(playerName, 300, 500); + genSkin(playerName, 300, 350); this._statsService.getMatrixDexPlayerStats(playerName).subscribe(stats => { this.latestPlayerStats = stats; - while(this.heartRows.length < stats.health) { - this.heartRows.push(0) - } + this.calculateHealthRows(this.latestPlayerStats.health); }) + + this.username = playerName + } + } + + private calculateHealthRows(health: number) { + health = 25 + const amountFullRows = Math.floor(health / this.HEALTH_HEARTS_PER_ROW); + const amountHearthsInLastRow = health-(amountFullRows*this.HEALTH_HEARTS_PER_ROW) + while (this.heartHeartsPerRowArr.length < this.HEALTH_HEARTS_PER_ROW ) { + this.heartHeartsPerRowArr.push(0) + } + this.heartRows = []; + while (this.heartRows.length < amountFullRows ) { + this.heartRows.push(0) + } + this.heartsInLastRow = []; + while (this.heartsInLastRow.length < amountHearthsInLastRow ) { + this.heartsInLastRow.push(0) } } diff --git a/frontend/src/app/home/home.component.ts b/frontend/src/app/home/home.component.ts index b374bf3..057bc93 100644 --- a/frontend/src/app/home/home.component.ts +++ b/frontend/src/app/home/home.component.ts @@ -6,9 +6,6 @@ import {DOCUMENT, NgFor} from "@angular/common"; import {PlayerStats} from "../models/player-stats"; import { NgForm } from '@angular/forms'; import {PlayerKill} from "../models/player-kill"; - -declare const genSkin: any; - @Component({ selector: 'app-home', templateUrl: './home.component.html', From f99b8389bccc2920ea8c0574c146ff6249eb647b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Apr 2023 07:15:40 +0000 Subject: [PATCH 2/2] chore(deps): bump org.junit.jupiter:junit-jupiter from 5.9.2 to 5.9.3 Bumps [org.junit.jupiter:junit-jupiter](https://github.com/junit-team/junit5) from 5.9.2 to 5.9.3. - [Release notes](https://github.com/junit-team/junit5/releases) - [Commits](https://github.com/junit-team/junit5/compare/r5.9.2...r5.9.3) --- updated-dependencies: - dependency-name: org.junit.jupiter:junit-jupiter dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 9f14080..0060379 100644 --- a/build.gradle +++ b/build.gradle @@ -104,7 +104,7 @@ dependencies { // Test dependencies - testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2' + testImplementation 'org.junit.jupiter:junit-jupiter:5.9.3' testImplementation 'org.mockito:mockito-core:4.11.0' testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.147.1' testImplementation 'org.assertj:assertj-core:3.24.1'