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

Prevent 4 Pressing same time tabu and giving the time pressed a value count

parent 2c5bfb68
Pipeline #343 passed with stages
in 5 minutes and 27 seconds
......@@ -39,7 +39,6 @@ export class TabuMiddlewareService {
}
getS2C(req: any): Promise<any> {
console.log("getS2C Request: ", req);
return this.request('POST', `${environment.tabuMiddlewareURL}getS2C`, req);
}
......
......@@ -53,7 +53,8 @@ export class GameComponent implements OnInit, OnDestroy {
private router: Router,
private activatedRoute: ActivatedRoute,
private isAllowedToPlay: IsAllowedToPlay,
private socketDataService: SocketDataService) {}
private socketDataService: SocketDataService) {
}
ngOnInit(): void {
this.activatedRoute.paramMap.subscribe(params => {
......@@ -108,7 +109,7 @@ export class GameComponent implements OnInit, OnDestroy {
});
}
onTimesUp(): void{
onTimesUp(): void {
this.unsubscribeAll();
this.router.navigate([this.sessionName + '/' + this.team]);
}
......@@ -124,28 +125,34 @@ export class GameComponent implements OnInit, OnDestroy {
}
}, 593);
}
startCountdown(): void {
setInterval(() => {
this.timeRemaining = this.timeRemaining -= 1;
}, 1000);
}
rightAnswer(): void{
this.newCard();
rightAnswer(): void {
this.service.addPoint
({
spielname: this.sessionName, team: this.team, red: this.gameStatus.red, blue: this.gameStatus.blue}).then(value => {
spielname: this.sessionName, team: this.team, red: this.gameStatus.red, blue: this.gameStatus.blue, cardID: this.gameStatus.activeCard
}).then(value => {
this.newCard();
this.gameStatus.red = JSON.parse(value.red);
this.gameStatus.blue = JSON.parse(value.blue);
});
}
wrongAnswer(): void{
wrongAnswer(): void {
this.newCard();
if (this.isExplainer) {
this.service.removePoint
({
spielname: this.sessionName, team: this.team, red: this.gameStatus.red, blue: this.gameStatus.blue
spielname: this.sessionName,
team: this.team,
red: this.gameStatus.red,
blue: this.gameStatus.blue,
cardID: this.gameStatus.activeCard
}).then(value => {
this.gameStatus.red = JSON.parse(value.red);
this.gameStatus.blue = JSON.parse(value.blue);
......@@ -159,7 +166,11 @@ export class GameComponent implements OnInit, OnDestroy {
}
this.service.removePoint
({
spielname: this.sessionName, team: opennentTeam, red: this.gameStatus.red, blue: this.gameStatus.blue
spielname: this.sessionName,
team: opennentTeam,
red: this.gameStatus.red,
blue: this.gameStatus.blue,
cardID: this.gameStatus.activeCard
}).then(value => {
this.gameStatus.red = JSON.parse(value.red);
this.gameStatus.blue = JSON.parse(value.blue);
......@@ -167,7 +178,7 @@ export class GameComponent implements OnInit, OnDestroy {
}
}
newCard(): void{
newCard(): void {
this.service.getS2C({spielname: this.sessionName}).then(value => {
const status = JSON.parse(value.status);
if (status) {
......@@ -197,11 +208,11 @@ export class GameComponent implements OnInit, OnDestroy {
this.gameStatus.redTurn = JSON.parse(value.redTurn);
this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer);
this.gameStatus.activeCard = JSON.parse(value.activeCard);
console.log("SOLUTION: ", this.cardInfo.cardID);
console.log('SOLUTION: ', this.cardInfo.cardID);
if (this.cardInfo.cardID === -1) {
console.log('I am in');
this.service.getCard({cardID: value.activeCard}).then(value1 => {
console.log("FIRST CARDS: ", value1);
console.log('FIRST CARDS: ', value1);
this.fillNewCard(value1);
});
}
......
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