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 {
console.log(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 @@
<mat-card class="transparent">
<div class="FloatLeftAndCenterElement">
<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>
</div>
<div class="CenterText">
......@@ -39,7 +39,7 @@
<br>
<mat-card-title>{{nextTeam}} ist am Zug:</mat-card-title>
<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>
</div>
......@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
import {GameStatus} from '../interface/gameStatus';
import {error} from 'selenium-webdriver';
@Component({
selector: 'app-overview',
......@@ -13,7 +14,8 @@ export class OverviewComponent implements OnInit {
blue = 'choose';
nextTeam = 'Blau';
team = '';
buttonPlayDisabled = true;
buttonNewGameDisabled = true;
buttonNextRoundDisabled = true;
sessionName = '';
membership = 'Wähle dein Team';
gameStatus: GameStatus = {
......@@ -36,13 +38,13 @@ export class OverviewComponent implements OnInit {
console.log('Team:', this.team);
if (this.team === 'red'){
this.membership = 'Du gehörst zu Team rot!';
this.buttonPlayDisabled = false;
this.buttonNewGameDisabled = false;
this.red = 'red';
this.blue = 'choose';
}
else if (this.team === 'blue'){
this.membership = 'Du gehörst zu Team blau!';
this.buttonPlayDisabled = false;
this.buttonNewGameDisabled = false;
this.blue = 'blue';
this.red = 'choose';
}
......@@ -64,9 +66,11 @@ export class OverviewComponent implements OnInit {
this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog);
if (this.gameStatus.redTurn){
this.nextTeam = 'Rot';
this.buttonNextRoundDisabled = this.team !== 'red';
}
else{
this.nextTeam = 'Blau';
this.buttonNextRoundDisabled = this.team !== 'blue';
}
}
console.log(this.gameStatus);
......@@ -76,9 +80,19 @@ export class OverviewComponent implements OnInit {
startGame(): void {
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 {
this.team = 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