Commit b89fc821 authored by Dennis Willers's avatar Dennis Willers 🏀

Tabooh Button gets disabled, if someone pressed it for 1500ms.

parent 9e5c3b77
Pipeline #367 passed with stages
in 5 minutes and 35 seconds
......@@ -74,4 +74,16 @@ export class SocketDataService {
});
});
}
getCanPressTabooh(sessionName: string): Observable<any> {
if (!this.isConnected) {
this.connect(sessionName);
}
this.sessionName = sessionName;
return new Observable(observer => {
this.socket.on(this.sessionName + ':canPressTabooh', (res: any) => {
observer.next(res);
});
});
}
}
......@@ -46,7 +46,7 @@
<br>
<button *ngIf="isExplainer" mat-raised-button color="primary" (click)="rightAnswer()">Richtig &#10004;</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()">Tabooh &#10008;</button>
<button mat-raised-button color="warn" [disabled]="PressTaboohDisabled" (click)="wrongAnswer()">Tabooh &#10008;</button>
<br>
<br>
<mat-card class="transparent">
......
......@@ -19,6 +19,8 @@ export class GameComponent implements OnInit, OnDestroy {
private ngUnsubscribe = new Subject();
subNewCard: any;
subEndRound: any;
subCanPressTabooh: any;
PressTaboohDisabled = false;
sessionName = '';
isWatchdog = false;
isExplainer = false;
......@@ -109,6 +111,12 @@ export class GameComponent implements OnInit, OnDestroy {
this.router.navigate([this.sessionName + '/' + this.team]);
}
});
this.subCanPressTabooh = this.socketDataService.getCanPressTabooh(this.sessionName)
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(data => {
console.log('Status Tabooh can pressed: ', data);
this.PressTaboohDisabled = !JSON.parse(data);
});
}
onTimesUp(): 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