Commit 89c47993 authored by Dennis Willers's avatar Dennis Willers 🏀

Anzeige wie viele Spieler in einem Raum sind und wie viele Spieler welchem Team beigetreten sind

parent c03bc8ec
Pipeline #394 failed with stages
in 48 seconds
This diff is collapsed.
{ {
"name": "tabu", "name": "tabooh",
"version": "0.0.0", "version": "2.2",
"scripts": { "scripts": {
"ng": "ng", "ng": "ng",
"start": "ng serve", "start": "ng serve",
......
...@@ -31,6 +31,7 @@ import { RoundHistoryComponent } from './round-history/round-history.component'; ...@@ -31,6 +31,7 @@ import { RoundHistoryComponent } from './round-history/round-history.component';
import {MatTableModule} from '@angular/material/table'; import {MatTableModule} from '@angular/material/table';
import {MatTreeModule} from '@angular/material/tree'; import {MatTreeModule} from '@angular/material/tree';
import {ViewModus} from './dao/viewModus'; import {ViewModus} from './dao/viewModus';
import {MatBadgeModule} from '@angular/material/badge';
@NgModule({ @NgModule({
declarations: [ declarations: [
...@@ -64,6 +65,7 @@ import {ViewModus} from './dao/viewModus'; ...@@ -64,6 +65,7 @@ import {ViewModus} from './dao/viewModus';
MatTooltipModule, MatTooltipModule,
MatTableModule, MatTableModule,
MatTreeModule, MatTreeModule,
MatBadgeModule
], ],
providers: [ providers: [
IsAllowedToPlay, IsAllowedToPlay,
......
...@@ -97,4 +97,20 @@ export class SocketDataService { ...@@ -97,4 +97,20 @@ export class SocketDataService {
}); });
}); });
} }
getSessionPlayers(sessionName: string): Observable<any> {
if (!this.isConnected) {
this.connect(sessionName);
}
this.sessionName = sessionName;
return new Observable(observer => {
this.socket.on(this.sessionName + ':sessionPlayers', (res: any) => {
observer.next(res);
});
});
}
updateSessionPlayers(sessionName: string, team: number, action: number): void {
this.socket.emit('sessionPlayers', {sessionName, team, newAction: action});
}
} }
...@@ -134,8 +134,8 @@ export class GameComponent implements OnInit, OnDestroy { ...@@ -134,8 +134,8 @@ export class GameComponent implements OnInit, OnDestroy {
this.timerInterval = setInterval(() => { this.timerInterval = setInterval(() => {
this.timePassed = this.timePassed += 1; this.timePassed = this.timePassed += 1;
this.timeLeft = (this.TIME_LIMIT - this.timePassed); this.timeLeft = (this.TIME_LIMIT - this.timePassed);
if (this.timeLeft === 0) { if (this.timeLeft === -2) {
// this.onTimesUp(); this.onTimesUp();
} }
}, 593); }, 593);
} }
......
...@@ -85,8 +85,8 @@ export class GuesserComponent implements OnInit, OnDestroy { ...@@ -85,8 +85,8 @@ export class GuesserComponent implements OnInit, OnDestroy {
this.timerInterval = setInterval(() => { this.timerInterval = setInterval(() => {
this.timePassed = this.timePassed += 1; this.timePassed = this.timePassed += 1;
this.timeLeft = (this.TIME_LIMIT - this.timePassed); this.timeLeft = (this.TIME_LIMIT - this.timePassed);
if (this.timeLeft === 0) { if (this.timeLeft === -2) {
//this.onTimesUp(); this.onTimesUp();
} }
}, 593); }, 593);
} }
......
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
<br> <br>
<div data-aos="zoom-out-right" data-aos-duration="250"> <div data-aos="zoom-out-right" data-aos-duration="250">
<mat-card class="transparent"> <mat-card class="transparent">
<mat-card-subtitle>Tabooh-Version: 2.1</mat-card-subtitle> <mat-card-subtitle>Tabooh-Version: 2.2</mat-card-subtitle>
<mat-card-subtitle>Zuletzt geändert am: 09.04.2021</mat-card-subtitle> <mat-card-subtitle>Zuletzt geändert am: 11.04.2021</mat-card-subtitle>
<mat-card-content> <mat-card-content>
<button mat-raised-button color="primary" (click)="goToStartpage()">Zur Startseite</button> <button mat-raised-button color="primary" (click)="goToStartpage()">Zur Startseite</button>
</mat-card-content> </mat-card-content>
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<button matTooltip="Neues Spiel starten" [disabled]="buttonNewGameDisabled || gameStatus.activeExplainer == 1" mat-raised-button color="primary" (click)="startGame()"> <button matTooltip="Neues Spiel starten" [disabled]="buttonNewGameDisabled || gameStatus.activeExplainer == 1" mat-raised-button color="primary" (click)="startGame()">
<mat-icon color = "white" aria-hidden="false">autorenew</mat-icon> <mat-icon color = "white" aria-hidden="false">autorenew</mat-icon>
</button> </button>
<mat-icon *ngIf="view === 'mobileView'" class="peopleInSessionRight" matBadge="{{totalPlayers}}" matBadgeSize="small" matBadgeColor="primary" aria-hidden="false" aria-label="home icon blue">people</mat-icon>
</div> </div>
<br *ngIf="view === 'mobileView'"> <br *ngIf="view === 'mobileView'">
<br *ngIf="view === 'mobileView'"> <br *ngIf="view === 'mobileView'">
...@@ -29,16 +30,17 @@ ...@@ -29,16 +30,17 @@
<mat-icon color = "white" aria-hidden="false">autorenew</mat-icon> <mat-icon color = "white" aria-hidden="false">autorenew</mat-icon>
</button> </button>
</div> </div>
<mat-icon *ngIf="view !== 'mobileView'" class="peopleInSessionRight" matBadge="{{totalPlayers}}" matBadgeSize="small" matBadgeColor="primary" aria-hidden="false" aria-label="home icon blue">people</mat-icon>
<div class="CenterText"> <div class="CenterText">
<h2 *ngIf="view === 'mobileView'" class="textMobileView">{{membership}}</h2> <h2 *ngIf="view === 'mobileView'" class="textMobileView">{{membership}}</h2>
<h2 *ngIf="view !== 'mobileView'">{{membership}}</h2> <h2 *ngIf="view !== 'mobileView'">{{membership}}</h2>
</div> </div>
</div> </div>
<button mat-raised-button class = "{{red}}" (click)="joinTeam('red')"> <button mat-raised-button class = "{{red}}" (click)="joinTeam('red')">
<mat-icon color = "warn" aria-hidden="false" aria-label="home icon red">home</mat-icon> <mat-icon matBadge="{{redPlayers}}" matBadgeSize="small" matBadgeColor="primary" color = "warn" aria-hidden="false" aria-label="home icon red" >home</mat-icon>
</button> </button>
<button mat-raised-button class = "{{blue}}" (click)="joinTeam('blue')"> <button mat-raised-button class = "{{blue}}" (click)="joinTeam('blue')">
<mat-icon style="color: darkblue" aria-hidden="false" aria-label="home icon blue">home</mat-icon> <mat-icon style="color: darkblue" matBadge="{{bluePlayers}}" matBadgeSize="small" aria-hidden="false" aria-label="home icon blue">home</mat-icon>
</button> </button>
</mat-card> </mat-card>
<br> <br>
......
...@@ -14,11 +14,13 @@ th{ ...@@ -14,11 +14,13 @@ th{
.blue{ .blue{
margin: 5px; margin: 5px;
padding-top: 2px;
background-color: rgba(0,0,139,0.5); background-color: rgba(0,0,139,0.5);
} }
.red{ .red{
margin: 5px; margin: 5px;
padding-top: 2px;
background-color: rgba(200, 0, 0, 0.3); background-color: rgba(200, 0, 0, 0.3);
} }
...@@ -29,16 +31,26 @@ th{ ...@@ -29,16 +31,26 @@ th{
.redfont{ .redfont{
margin: 5px; margin: 5px;
padding-top: 2px;
color: rgba(200, 0, 0); color: rgba(200, 0, 0);
} }
.choose{ .choose{
margin: 5px; margin: 5px;
padding-top: 2px;
cursor: pointer; cursor: pointer;
} }
.FloatLeftAndCenterElement{width:100%;} .FloatLeftAndCenterElement{width:100%;}
.spaceBetween {
display: flex;
justify-content: space-between;
align-content: center;
align-items: center;
}
.newStartButtonLeft{float:left;width:100px;} .newStartButtonLeft{float:left;width:100px;}
.peopleInSessionRight{float:right; margin-top: 4px}
.CenterText{margin:0 auto;width:250px;} .CenterText{margin:0 auto;width:250px;}
.spinner-wrapper { .spinner-wrapper {
...@@ -62,3 +74,7 @@ th{ ...@@ -62,3 +74,7 @@ th{
.textMobileView { .textMobileView {
display: inline; display: inline;
} }
.peopleRight {
float: right;
}
...@@ -22,12 +22,17 @@ export class OverviewComponent implements OnInit, OnDestroy { ...@@ -22,12 +22,17 @@ export class OverviewComponent implements OnInit, OnDestroy {
subNewRound: any; subNewRound: any;
subEndRound: any; subEndRound: any;
subHistoryChanged: any; subHistoryChanged: any;
subSessionPlayers: any;
wantToBeExplainer = false; wantToBeExplainer = false;
isActiveRound = false; isActiveRound = false;
red = 'choose'; red = 'choose';
blue = 'choose'; blue = 'choose';
totalPlayers = 1;
redPlayers = 0;
bluePlayers = 0;
nextTeam = 'Blau'; nextTeam = 'Blau';
team = ''; team = '';
teamNumber = 0;
buttonNewGameDisabled = true; buttonNewGameDisabled = true;
buttonNextRoundDisabled = true; buttonNextRoundDisabled = true;
sessionName = ''; sessionName = '';
...@@ -68,6 +73,7 @@ export class OverviewComponent implements OnInit, OnDestroy { ...@@ -68,6 +73,7 @@ export class OverviewComponent implements OnInit, OnDestroy {
this.activatedRoute.paramMap.subscribe(params => { this.activatedRoute.paramMap.subscribe(params => {
this.sessionName = String(params.get('sessionName')).toLowerCase(); this.sessionName = String(params.get('sessionName')).toLowerCase();
this.team = String(params.get('team')); this.team = String(params.get('team'));
this.teamToTeamNumber(this.team);
this.getSocketData(); this.getSocketData();
this.service.isSession({spielname: this.sessionName}).then(value => { this.service.isSession({spielname: this.sessionName}).then(value => {
if (!JSON.parse(value.status)) { if (!JSON.parse(value.status)) {
...@@ -124,6 +130,15 @@ export class OverviewComponent implements OnInit, OnDestroy { ...@@ -124,6 +130,15 @@ export class OverviewComponent implements OnInit, OnDestroy {
} }
} }
}); });
this.subSessionPlayers = this.socketDataService.getSessionPlayers(this.sessionName)
.pipe(takeUntil(this.ngUnsubscribe)).subscribe(data => {
if (data.hasOwnProperty('total')) {
this.totalPlayers = data.total;
this.redPlayers = data.red;
this.bluePlayers = data.blue;
}
});
this.socketDataService.updateSessionPlayers(this.sessionName, this.teamNumber, 1);
} }
selectTeam(): void { selectTeam(): void {
...@@ -165,7 +180,7 @@ export class OverviewComponent implements OnInit, OnDestroy { ...@@ -165,7 +180,7 @@ export class OverviewComponent implements OnInit, OnDestroy {
const status = JSON.parse(value.status); const status = JSON.parse(value.status);
if (status) { if (status) {
this.getGameStatus(); this.getGameStatus();
const audio = "../../../assets/sounds/ui_refresh-feed.ogg"; const audio = '../../../assets/sounds/ui_refresh-feed.ogg';
this.playAudio(audio); this.playAudio(audio);
} }
}).catch(reason => console.log(reason)); }).catch(reason => console.log(reason));
...@@ -187,7 +202,7 @@ export class OverviewComponent implements OnInit, OnDestroy { ...@@ -187,7 +202,7 @@ export class OverviewComponent implements OnInit, OnDestroy {
this.isAllowedToPlay.role = 'explainer'; this.isAllowedToPlay.role = 'explainer';
this.router.navigate([this.sessionName + '/' + this.team + '/explainer', ]); this.router.navigate([this.sessionName + '/' + this.team + '/explainer', ]);
this.wantToBeExplainer = true; this.wantToBeExplainer = true;
const audio = "../../../assets/sounds/state-change_confirm-up.ogg"; const audio = '../../../assets/sounds/state-change_confirm-up.ogg';
this.playAudio(audio); this.playAudio(audio);
}); });
}); });
...@@ -195,16 +210,29 @@ export class OverviewComponent implements OnInit, OnDestroy { ...@@ -195,16 +210,29 @@ export class OverviewComponent implements OnInit, OnDestroy {
joinTeam(team: string): void { joinTeam(team: string): void {
this.team = team; this.team = team;
this.teamToTeamNumber(this.team);
this.unsubscribeAll(); this.unsubscribeAll();
this.location.replaceState(this.sessionName + '/' + team); this.location.replaceState(this.sessionName + '/' + team);
this.selectTeam(); this.selectTeam();
this.canStartGame(); this.canStartGame();
this.unsubscribeAll(); this.unsubscribeAll();
this.getSocketData(); this.getSocketData();
const audio = "../../../assets/sounds/ui_unlock.ogg"; const audio = '../../../assets/sounds/ui_unlock.ogg';
this.playAudio(audio); this.playAudio(audio);
} }
teamToTeamNumber(team: string): void {
if (team === 'red') {
this.teamNumber = 1;
}
if (team === 'blue') {
this.teamNumber = 2;
}
if (team === '') {
this.teamNumber = 0;
}
}
getGameStatus(): void { getGameStatus(): void {
this.service.getGamestatus({spielname: this.sessionName}).then(value => { this.service.getGamestatus({spielname: this.sessionName}).then(value => {
this.fillGameStatus(value); this.fillGameStatus(value);
...@@ -269,7 +297,7 @@ export class OverviewComponent implements OnInit, OnDestroy { ...@@ -269,7 +297,7 @@ export class OverviewComponent implements OnInit, OnDestroy {
this.subEndRound.unsubscribe(); this.subEndRound.unsubscribe();
this.subNewGame.unsubscribe(); this.subNewGame.unsubscribe();
this.subHistoryChanged.unsubscribe(); this.subHistoryChanged.unsubscribe();
this.subSessionPlayers.unsubscribe();
this.ngUnsubscribe.next(); this.ngUnsubscribe.next();
this.ngUnsubscribe.complete(); this.ngUnsubscribe.complete();
} }
......
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