Loading src/app/app.module.ts +4 −1 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ import { GuesserComponent } from './guesser/guesser.component'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import {MatIconModule} from '@angular/material/icon'; import {MatIconModule} from '@angular/material/icon'; import {MatTooltipModule} from '@angular/material/tooltip'; import {MatTooltipModule} from '@angular/material/tooltip'; import {IsAllowedToPlay} from './dao/isAllowedToPlay'; @NgModule({ @NgModule({ declarations: [ declarations: [ Loading Loading @@ -52,7 +53,9 @@ import {MatTooltipModule} from '@angular/material/tooltip'; MatIconModule, MatIconModule, MatTooltipModule MatTooltipModule ], ], providers: [], providers: [ IsAllowedToPlay ], bootstrap: [AppComponent] bootstrap: [AppComponent] }) }) export class AppModule { } export class AppModule { } src/app/dao/isAllowedToPlay.ts 0 → 100644 +7 −0 Original line number Original line Diff line number Diff line import {Injectable} from '@angular/core'; @Injectable() export class IsAllowedToPlay { isAllowed = false; role = ''; } src/app/game/game.component.ts +18 −12 Original line number Original line Diff line number Diff line import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core'; 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, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router'; import {GameStatus} from '../interface/gameStatus'; import {GameStatus} from '../interface/gameStatus'; import {io} from 'socket.io-client'; import {io} from 'socket.io-client'; import {environment} from '../../environments/environment'; import {environment} from '../../environments/environment'; import {IsAllowedToPlay} from '../dao/isAllowedToPlay'; @Component({ @Component({ selector: 'app-game', selector: 'app-game', Loading Loading @@ -38,35 +38,41 @@ export class GameComponent implements OnInit { red: 0, red: 0, blue: 0, blue: 0, redTurn: true, redTurn: true, activeExplainer: false, activeExplainer: 1, activeWatchdog: false activeWatchdog: 1 }; }; team = ''; team = ''; color = 'primary'; color = 'primary'; mode: ProgressSpinnerMode = 'determinate'; value = 50; value = 50; constructor(private service: TabuMiddlewareService, constructor(private service: TabuMiddlewareService, private router: Router, private router: Router, private activatedRoute: ActivatedRoute) {} private activatedRoute: ActivatedRoute, private isAllowedToPlay: IsAllowedToPlay) {} 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')); this.team = String(params.get('team')); const url = this.router.url.split('/'); const url = this.router.url.split('/'); const checkUser = url[url.length - 1]; const checkUser = url[url.length - 1]; if (checkUser === 'watchdog') { if (checkUser === 'watchdog') { if (!this.isAllowedToPlay.isAllowed || this.isAllowedToPlay.role !== 'watchdog') { this.router.navigate([this.sessionName + '/' + this.team]); } else { this.isWatchdog = true; this.isWatchdog = true; } } else if (checkUser === 'explainer') { } else if (checkUser === 'explainer') { if (!this.isAllowedToPlay.isAllowed || this.isAllowedToPlay.role !== 'explainer') { this.router.navigate([this.sessionName + '/' + this.team]); } else { this.isExplainer = true; this.isExplainer = true; this.service.getS2C({spielname: this.sessionName}); this.service.getS2C({spielname: this.sessionName}); } } } this.fillGamestatus(); this.fillGamestatus(); this.team = String(params.get('team')); this.socket = io(environment.tabuServerURL); this.socket = io(environment.tabuServerURL, { // WARNING: in that case, there is no fallback to long-polling transports: [ 'websocket' ] // or [ 'websocket', 'polling' ], which is the same thing }); this.listen(); this.listen(); }); }); this.startTimer(); this.startTimer(); Loading @@ -90,7 +96,7 @@ export class GameComponent implements OnInit { } } onTimesUp(): void{ onTimesUp(): void{ this.socket.disconnect() this.socket.disconnect(); this.router.navigate([this.sessionName + '/' + this.team]); this.router.navigate([this.sessionName + '/' + this.team]); } } Loading @@ -101,7 +107,7 @@ export class GameComponent implements OnInit { this.timeLeft = (this.TIME_LIMIT - this.timePassed); this.timeLeft = (this.TIME_LIMIT - this.timePassed); if (this.timeLeft === 0) { if (this.timeLeft === 0) { console.log('Times up!'); console.log('Times up!'); //this.onTimesUp(); this.onTimesUp(); } } }, 593); }, 593); } } Loading src/app/guesser/guesser.component.ts +13 −9 Original line number Original line Diff line number Diff line import { Component, OnInit } from '@angular/core'; import {Component, Input, OnInit} from '@angular/core'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {GameStatus} from '../interface/gameStatus'; import {GameStatus} from '../interface/gameStatus'; import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router'; import {io} from 'socket.io-client'; import {io} from 'socket.io-client'; import {environment} from '../../environments/environment'; import {environment} from '../../environments/environment'; import {IsAllowedToPlay} from '../dao/isAllowedToPlay'; @Component({ @Component({ selector: 'app-guesser', selector: 'app-guesser', templateUrl: './guesser.component.html', templateUrl: './guesser.component.html', Loading @@ -22,22 +23,25 @@ export class GuesserComponent implements OnInit { red: 0, red: 0, blue: 0, blue: 0, redTurn: true, redTurn: true, activeExplainer: false, activeExplainer: 1, activeWatchdog: false activeWatchdog: 1 }; }; team = ''; team = ''; constructor(private router: Router, private activatedRoute: ActivatedRoute, private service: TabuMiddlewareService) { } constructor(private router: Router, private activatedRoute: ActivatedRoute, private service: TabuMiddlewareService, private isAllowedToPlay: IsAllowedToPlay) { } 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')); this.team = String(params.get('team')); this.team = String(params.get('team')); if (!this.isAllowedToPlay.isAllowed || this.isAllowedToPlay.role !== 'guesser') { this.router.navigate([this.sessionName + '/' + this.team]); } this.fillGamestatus(); this.fillGamestatus(); this.socket = io(environment.tabuServerURL, { this.socket = io(environment.tabuServerURL); // WARNING: in that case, there is no fallback to long-polling transports: [ 'websocket' ] // or [ 'websocket', 'polling' ], which is the same thing }); this.listen(); this.listen(); }); }); this.startTimer(); this.startTimer(); Loading Loading @@ -71,7 +75,7 @@ export class GuesserComponent implements OnInit { this.timeLeft = (this.TIME_LIMIT - this.timePassed); this.timeLeft = (this.TIME_LIMIT - this.timePassed); if (this.timeLeft === 0) { if (this.timeLeft === 0) { console.log('Times up!'); console.log('Times up!'); //this.onTimesUp(); this.onTimesUp(); } } }, 593); }, 593); } } Loading src/app/interface/gameStatus.ts +2 −2 Original line number Original line Diff line number Diff line Loading @@ -3,6 +3,6 @@ export interface GameStatus { red: number; red: number; blue: number; blue: number; redTurn: boolean; redTurn: boolean; activeExplainer: boolean; activeExplainer: number; activeWatchdog: boolean; activeWatchdog: number; } } Loading
src/app/app.module.ts +4 −1 Original line number Original line Diff line number Diff line Loading @@ -23,6 +23,7 @@ import { GuesserComponent } from './guesser/guesser.component'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import {MatSlideToggleModule} from '@angular/material/slide-toggle'; import {MatIconModule} from '@angular/material/icon'; import {MatIconModule} from '@angular/material/icon'; import {MatTooltipModule} from '@angular/material/tooltip'; import {MatTooltipModule} from '@angular/material/tooltip'; import {IsAllowedToPlay} from './dao/isAllowedToPlay'; @NgModule({ @NgModule({ declarations: [ declarations: [ Loading Loading @@ -52,7 +53,9 @@ import {MatTooltipModule} from '@angular/material/tooltip'; MatIconModule, MatIconModule, MatTooltipModule MatTooltipModule ], ], providers: [], providers: [ IsAllowedToPlay ], bootstrap: [AppComponent] bootstrap: [AppComponent] }) }) export class AppModule { } export class AppModule { }
src/app/dao/isAllowedToPlay.ts 0 → 100644 +7 −0 Original line number Original line Diff line number Diff line import {Injectable} from '@angular/core'; @Injectable() export class IsAllowedToPlay { isAllowed = false; role = ''; }
src/app/game/game.component.ts +18 −12 Original line number Original line Diff line number Diff line import {Component, OnInit} from '@angular/core'; import {Component, OnInit} from '@angular/core'; 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, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router'; import {GameStatus} from '../interface/gameStatus'; import {GameStatus} from '../interface/gameStatus'; import {io} from 'socket.io-client'; import {io} from 'socket.io-client'; import {environment} from '../../environments/environment'; import {environment} from '../../environments/environment'; import {IsAllowedToPlay} from '../dao/isAllowedToPlay'; @Component({ @Component({ selector: 'app-game', selector: 'app-game', Loading Loading @@ -38,35 +38,41 @@ export class GameComponent implements OnInit { red: 0, red: 0, blue: 0, blue: 0, redTurn: true, redTurn: true, activeExplainer: false, activeExplainer: 1, activeWatchdog: false activeWatchdog: 1 }; }; team = ''; team = ''; color = 'primary'; color = 'primary'; mode: ProgressSpinnerMode = 'determinate'; value = 50; value = 50; constructor(private service: TabuMiddlewareService, constructor(private service: TabuMiddlewareService, private router: Router, private router: Router, private activatedRoute: ActivatedRoute) {} private activatedRoute: ActivatedRoute, private isAllowedToPlay: IsAllowedToPlay) {} 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')); this.team = String(params.get('team')); const url = this.router.url.split('/'); const url = this.router.url.split('/'); const checkUser = url[url.length - 1]; const checkUser = url[url.length - 1]; if (checkUser === 'watchdog') { if (checkUser === 'watchdog') { if (!this.isAllowedToPlay.isAllowed || this.isAllowedToPlay.role !== 'watchdog') { this.router.navigate([this.sessionName + '/' + this.team]); } else { this.isWatchdog = true; this.isWatchdog = true; } } else if (checkUser === 'explainer') { } else if (checkUser === 'explainer') { if (!this.isAllowedToPlay.isAllowed || this.isAllowedToPlay.role !== 'explainer') { this.router.navigate([this.sessionName + '/' + this.team]); } else { this.isExplainer = true; this.isExplainer = true; this.service.getS2C({spielname: this.sessionName}); this.service.getS2C({spielname: this.sessionName}); } } } this.fillGamestatus(); this.fillGamestatus(); this.team = String(params.get('team')); this.socket = io(environment.tabuServerURL); this.socket = io(environment.tabuServerURL, { // WARNING: in that case, there is no fallback to long-polling transports: [ 'websocket' ] // or [ 'websocket', 'polling' ], which is the same thing }); this.listen(); this.listen(); }); }); this.startTimer(); this.startTimer(); Loading @@ -90,7 +96,7 @@ export class GameComponent implements OnInit { } } onTimesUp(): void{ onTimesUp(): void{ this.socket.disconnect() this.socket.disconnect(); this.router.navigate([this.sessionName + '/' + this.team]); this.router.navigate([this.sessionName + '/' + this.team]); } } Loading @@ -101,7 +107,7 @@ export class GameComponent implements OnInit { this.timeLeft = (this.TIME_LIMIT - this.timePassed); this.timeLeft = (this.TIME_LIMIT - this.timePassed); if (this.timeLeft === 0) { if (this.timeLeft === 0) { console.log('Times up!'); console.log('Times up!'); //this.onTimesUp(); this.onTimesUp(); } } }, 593); }, 593); } } Loading
src/app/guesser/guesser.component.ts +13 −9 Original line number Original line Diff line number Diff line import { Component, OnInit } from '@angular/core'; import {Component, Input, OnInit} from '@angular/core'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {GameStatus} from '../interface/gameStatus'; import {GameStatus} from '../interface/gameStatus'; import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router'; import {io} from 'socket.io-client'; import {io} from 'socket.io-client'; import {environment} from '../../environments/environment'; import {environment} from '../../environments/environment'; import {IsAllowedToPlay} from '../dao/isAllowedToPlay'; @Component({ @Component({ selector: 'app-guesser', selector: 'app-guesser', templateUrl: './guesser.component.html', templateUrl: './guesser.component.html', Loading @@ -22,22 +23,25 @@ export class GuesserComponent implements OnInit { red: 0, red: 0, blue: 0, blue: 0, redTurn: true, redTurn: true, activeExplainer: false, activeExplainer: 1, activeWatchdog: false activeWatchdog: 1 }; }; team = ''; team = ''; constructor(private router: Router, private activatedRoute: ActivatedRoute, private service: TabuMiddlewareService) { } constructor(private router: Router, private activatedRoute: ActivatedRoute, private service: TabuMiddlewareService, private isAllowedToPlay: IsAllowedToPlay) { } 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')); this.team = String(params.get('team')); this.team = String(params.get('team')); if (!this.isAllowedToPlay.isAllowed || this.isAllowedToPlay.role !== 'guesser') { this.router.navigate([this.sessionName + '/' + this.team]); } this.fillGamestatus(); this.fillGamestatus(); this.socket = io(environment.tabuServerURL, { this.socket = io(environment.tabuServerURL); // WARNING: in that case, there is no fallback to long-polling transports: [ 'websocket' ] // or [ 'websocket', 'polling' ], which is the same thing }); this.listen(); this.listen(); }); }); this.startTimer(); this.startTimer(); Loading Loading @@ -71,7 +75,7 @@ export class GuesserComponent implements OnInit { this.timeLeft = (this.TIME_LIMIT - this.timePassed); this.timeLeft = (this.TIME_LIMIT - this.timePassed); if (this.timeLeft === 0) { if (this.timeLeft === 0) { console.log('Times up!'); console.log('Times up!'); //this.onTimesUp(); this.onTimesUp(); } } }, 593); }, 593); } } Loading
src/app/interface/gameStatus.ts +2 −2 Original line number Original line Diff line number Diff line Loading @@ -3,6 +3,6 @@ export interface GameStatus { red: number; red: number; blue: number; blue: number; redTurn: boolean; redTurn: boolean; activeExplainer: boolean; activeExplainer: number; activeWatchdog: boolean; activeWatchdog: number; } }