Commit 3192fcd4 authored by Dennis Willers's avatar Dennis Willers 🏀

Implement Services from Joshua and create Logic for nextRound Button

parent fbd9fe2b
...@@ -53,4 +53,19 @@ export class TabuMiddlewareService { ...@@ -53,4 +53,19 @@ export class TabuMiddlewareService {
console.log(req); console.log(req);
return this.request('POST', `${environment.tabuMiddlewareURL}removePoint`, req); return this.request('POST', `${environment.tabuMiddlewareURL}removePoint`, req);
} }
newGame(req: any): Promise<any> {
console.log(req);
return this.request('POST', `${environment.tabuMiddlewareURL}newGame`, req);
}
newRound(req: any): Promise<any> {
console.log(req);
return this.request('POST', `${environment.tabuMiddlewareURL}newRound`, req);
}
endRound(req: any): Promise<any> {
console.log(req);
return this.request('POST', `${environment.tabuMiddlewareURL}endRound`, req);
}
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<mat-card class="transparent"> <mat-card class="transparent">
<div class="FloatLeftAndCenterElement"> <div class="FloatLeftAndCenterElement">
<div class="newStartButtonLeft"> <div class="newStartButtonLeft">
<button matTooltip="Neues Spiel starten" [disabled]="buttonPlayDisabled" mat-raised-button color="primary" (click)="startGame()"> <button matTooltip="Neues Spiel starten" [disabled]="buttonNewGameDisabled" mat-raised-button color="primary" (click)="startGame()">
<mat-icon color = "white" aria-hidden="false">autorenew</mat-icon></button> <mat-icon color = "white" aria-hidden="false">autorenew</mat-icon></button>
</div> </div>
<div class="CenterText"> <div class="CenterText">
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<br> <br>
<mat-card-title>{{nextTeam}} ist am Zug:</mat-card-title> <mat-card-title>{{nextTeam}} ist am Zug:</mat-card-title>
<br> <br>
<button [disabled]="buttonPlayDisabled" mat-raised-button color="primary">Nächste Runde</button> <button [disabled]="buttonNextRoundDisabled" mat-raised-button color="primary" (click)="nextRound()">Nächste Runde</button>
</mat-card-actions> </mat-card-actions>
</mat-card> </mat-card>
</div> </div>
...@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
import {GameStatus} from '../interface/gameStatus'; import {GameStatus} from '../interface/gameStatus';
import {error} from 'selenium-webdriver';
@Component({ @Component({
selector: 'app-overview', selector: 'app-overview',
...@@ -13,7 +14,8 @@ export class OverviewComponent implements OnInit { ...@@ -13,7 +14,8 @@ export class OverviewComponent implements OnInit {
blue = 'choose'; blue = 'choose';
nextTeam = 'Blau'; nextTeam = 'Blau';
team = ''; team = '';
buttonPlayDisabled = true; buttonNewGameDisabled = true;
buttonNextRoundDisabled = true;
sessionName = ''; sessionName = '';
membership = 'Wähle dein Team'; membership = 'Wähle dein Team';
gameStatus: GameStatus = { gameStatus: GameStatus = {
...@@ -36,13 +38,13 @@ export class OverviewComponent implements OnInit { ...@@ -36,13 +38,13 @@ export class OverviewComponent implements OnInit {
console.log('Team:', this.team); console.log('Team:', this.team);
if (this.team === 'red'){ if (this.team === 'red'){
this.membership = 'Du gehörst zu Team rot!'; this.membership = 'Du gehörst zu Team rot!';
this.buttonPlayDisabled = false; this.buttonNewGameDisabled = false;
this.red = 'red'; this.red = 'red';
this.blue = 'choose'; this.blue = 'choose';
} }
else if (this.team === 'blue'){ else if (this.team === 'blue'){
this.membership = 'Du gehörst zu Team blau!'; this.membership = 'Du gehörst zu Team blau!';
this.buttonPlayDisabled = false; this.buttonNewGameDisabled = false;
this.blue = 'blue'; this.blue = 'blue';
this.red = 'choose'; this.red = 'choose';
} }
...@@ -64,9 +66,11 @@ export class OverviewComponent implements OnInit { ...@@ -64,9 +66,11 @@ export class OverviewComponent implements OnInit {
this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog); this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog);
if (this.gameStatus.redTurn){ if (this.gameStatus.redTurn){
this.nextTeam = 'Rot'; this.nextTeam = 'Rot';
this.buttonNextRoundDisabled = this.team !== 'red';
} }
else{ else{
this.nextTeam = 'Blau'; this.nextTeam = 'Blau';
this.buttonNextRoundDisabled = this.team !== 'blue';
} }
} }
console.log(this.gameStatus); console.log(this.gameStatus);
...@@ -76,9 +80,19 @@ export class OverviewComponent implements OnInit { ...@@ -76,9 +80,19 @@ export class OverviewComponent implements OnInit {
startGame(): void { startGame(): void {
if (this.team === 'red' || this.team === 'blue') { if (this.team === 'red' || this.team === 'blue') {
this.router.navigate([this.router.url + '/explainer']); this.service.newGame({spielname: this.sessionName}).then(value => {
const status = JSON.parse(value.status);
if (status) {
this.router.navigate([this.router.url + '/explainer']);
}
}).catch(reason => console.log(reason));
} }
} }
nextRound(): void {
this.router.navigate([this.router.url + '/explainer']);
}
joinTeam(team: string): void { joinTeam(team: string): void {
this.team = team; this.team = team;
this.router.navigate([this.sessionName + '/' + team]); this.router.navigate([this.sessionName + '/' + team]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment