Skip to content

Commit

Permalink
Fixed Highscore Entry with #28 #29 #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik.Sigmund committed Oct 17, 2023
1 parent 4001f64 commit 278443d
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 4 deletions.
17 changes: 17 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

VERSION=$(jq -r '.version' package.json)

echo "new Version: $VERSION"

podman build --platform=linux/amd64 --no-cache -t bibelquiz-frontend:latest .

echo "tagging and pushing to dockerhub"
podman tag bibelquiz-frontend:latest dsigmund/bibelquiz-frontend:latest
podman tag bibelquiz-frontend:latest dsigmund/bibelquiz-frontend:"$VERSION"

echo "pushing to dockerhub"
podman push dsigmund/bibelquiz-frontend:latest
podman push dsigmund/bibelquiz-frontend:"$VERSION"

echo "done"
1 change: 1 addition & 0 deletions src/app/changelog/changelog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Component, OnInit } from '@angular/core';
})
export class ChangelogComponent implements OnInit {
changes = [
"1.0.46;Die Eingabe von Namen wurde auf 20 Zeichen beschränkt;Highscorese können nicht mehr mehrfach abgesendet werden;Leere Namen können nicht mehr eingetragen werden",
"1.0.45;Es wird das Datum bei den Highscores angezeigt",
"1.0.44;Es werden nun alle Highscores angezeigt, nicht nur die Top Ten.",
"1.0.43;Anpassung Wording",
Expand Down
6 changes: 3 additions & 3 deletions src/app/game/game.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ <h2 id="countdown">{{countdown}}</h2>
<mat-form-field id="nameInput" appearance="standard">
<mat-label>Name:</mat-label>
<input type="text" matInput [(ngModel)]="name" autofocus/>
<mat-hint>Dein richtiger oder besser noch ein ausgedachter Name</mat-hint>
<mat-hint>Dein richtiger oder besser noch ein ausgedachter Name (nicht länger als 20 Zeichen)</mat-hint>
</mat-form-field>
<br/>
<br/>
<button mat-raised-button color="primary" class="half-button" (click)="inputHighscore()" >
<button mat-raised-button color="primary" class="half-button" (click)="inputHighscore()" [disabled]="highscoreSent" >
Eintragen
</button>
<button mat-raised-button color="primary" class="half-button" (click)="doNotInputHighscore()" >
<button mat-raised-button color="primary" class="half-button" (click)="doNotInputHighscore()" [disabled]="highscoreSent">
Nein Danke
</button>
<p>
Expand Down
12 changes: 12 additions & 0 deletions src/app/game/game.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class GameComponent implements OnInit {
canvas: any;
saveName: boolean = false;
name: string = '';
highscoreSent: boolean = false;
entry = false;
constructor(
private backend: BackendService,
Expand Down Expand Up @@ -273,13 +274,24 @@ export class GameComponent implements OnInit {
}

public inputHighscore(): void {
if (this.name.length < 1) { // no name entered
return;
}
if (this.highscoreSent) { // already sent
return;
}
if (this.name.length > 20) { // name too long
return;
}
this.highscoreSent = true;
localStorage.setItem("name", this.name)
this.highscoreService.enterScore({
username: this.name,
score: this.points.toString(),
difficulty: this.difficulty.id
}).subscribe(result => {
console.log('score entered')
this.highscoreSent = false;
this.entry = true;
this.state = GameState.Again;
});
Expand Down
3 changes: 2 additions & 1 deletion src/app/services/highscore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export class HighscoreService {
return this.httpClient.post(environment.backend + '/highscore', {
username: data.username,
score: parseInt(data.score),
difficulty: data.difficulty
difficulty: data.difficulty,
gamemode: 1 // default value, will be replaced
}, {
headers: new HttpHeaders({
'Accept': 'text/html, application/xhtml+xml, */*',
Expand Down

0 comments on commit 278443d

Please sign in to comment.