Commit 866e8b3f authored by Dennis Willers's avatar Dennis Willers 🏀

Change designe and routing handling for explainer watchdog

parent d42b70d9
Pipeline #305 passed with stages
in 5 minutes and 19 seconds
...@@ -33,10 +33,12 @@ ...@@ -33,10 +33,12 @@
</h2> </h2>
</mat-card> </mat-card>
<br> <br>
<button mat-raised-button color="primary" (click)="rightAnswer()">Richtig &#10004;</button> <button *ngIf="isExplainer" mat-raised-button color="primary" (click)="rightAnswer()">Richtig &#10004;</button>
<button mat-raised-button color="accent" style="margin: 40px" (click)="newCard()">Überspringen &#187;</button> <button *ngIf="isExplainer" mat-raised-button color="accent" style="margin: 40px" (click)="newCard()">Überspringen &#187;</button>
<button mat-raised-button color="warn" (click)="wrongAnswer()">Tabu &#10008;</button> <button mat-raised-button color="warn" (click)="wrongAnswer()">Tabu &#10008;</button>
<br> <br>
<br>
<br>
<mat-card class="transparent"> <mat-card class="transparent">
<mat-card-title>Spielstand</mat-card-title> <mat-card-title>Spielstand</mat-card-title>
<mat-card-content> <mat-card-content>
......
...@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'; ...@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core';
import {ProgressSpinnerMode} from '@angular/material/progress-spinner'; import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
import {CardInfo} from '../interface/cardInfo'; import {CardInfo} from '../interface/cardInfo';
import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
import {ActivatedRoute} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {GameStatus} from '../interface/gameStatus'; import {GameStatus} from '../interface/gameStatus';
@Component({ @Component({
...@@ -13,6 +13,8 @@ import {GameStatus} from '../interface/gameStatus'; ...@@ -13,6 +13,8 @@ import {GameStatus} from '../interface/gameStatus';
export class GameComponent implements OnInit { export class GameComponent implements OnInit {
sessionName = ''; sessionName = '';
isWatchdog = false;
isExplainer = false;
cardInfo: CardInfo = { cardInfo: CardInfo = {
cardID: -1, cardID: -1,
solution: '', solution: '',
...@@ -37,11 +39,19 @@ export class GameComponent implements OnInit { ...@@ -37,11 +39,19 @@ export class GameComponent implements OnInit {
mode: ProgressSpinnerMode = 'determinate'; mode: ProgressSpinnerMode = 'determinate';
value = 50; value = 50;
constructor(private service: TabuMiddlewareService, constructor(private service: TabuMiddlewareService,
private router: Router,
private activatedRoute: ActivatedRoute) {} private activatedRoute: ActivatedRoute) {}
ngOnInit(): void { ngOnInit(): void {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
this.sessionName = String(params.get('sessionName')); this.sessionName = String(params.get('sessionName'));
const url = this.router.url.split('/');
const checkUser = url[url.length - 1];
if (checkUser === 'watchdog') {
this.isWatchdog = true;
} else if (checkUser === 'explainer') {
this.isExplainer = true;
}
this.service.getGamestatus({spielname: this.sessionName}).then(value => { this.service.getGamestatus({spielname: this.sessionName}).then(value => {
const status = JSON.parse(value.status); const status = JSON.parse(value.status);
if (status) { if (status) {
......
...@@ -11,7 +11,7 @@ import {GameStatus} from '../interface/gameStatus'; ...@@ -11,7 +11,7 @@ import {GameStatus} from '../interface/gameStatus';
export class OverviewComponent implements OnInit { export class OverviewComponent implements OnInit {
red = 'choose'; red = 'choose';
blue = 'choose'; blue = 'choose';
nextTeam = ''; nextTeam = 'Blau';
team = ''; team = '';
buttonPlayDisabled = true; buttonPlayDisabled = true;
sessionName = ''; sessionName = '';
...@@ -53,12 +53,6 @@ export class OverviewComponent implements OnInit { ...@@ -53,12 +53,6 @@ export class OverviewComponent implements OnInit {
this.router.navigate(['error']); this.router.navigate(['error']);
return; return;
} }
if (this.gameStatus.redTurn){
this.nextTeam = 'Rot';
}
else{
this.nextTeam = 'Blau';
}
this.service.getGamestatus({spielname: this.sessionName}).then(value => { this.service.getGamestatus({spielname: this.sessionName}).then(value => {
const status = JSON.parse(value.status); const status = JSON.parse(value.status);
if (status) { if (status) {
...@@ -68,6 +62,12 @@ export class OverviewComponent implements OnInit { ...@@ -68,6 +62,12 @@ export class OverviewComponent implements OnInit {
this.gameStatus.redTurn = JSON.parse(value.redTurn); this.gameStatus.redTurn = JSON.parse(value.redTurn);
this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer); this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer);
this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog); this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog);
if (this.gameStatus.redTurn){
this.nextTeam = 'Rot';
}
else{
this.nextTeam = 'Blau';
}
} }
console.log(this.gameStatus); console.log(this.gameStatus);
}).catch(reason => console.log(reason)); }).catch(reason => console.log(reason));
...@@ -76,7 +76,7 @@ export class OverviewComponent implements OnInit { ...@@ -76,7 +76,7 @@ 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 + '/watchdog']); this.router.navigate([this.router.url + '/explainer']);
} }
} }
joinTeam(team: string): void { joinTeam(team: string): void {
......
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