From 98fe79c396c4d974b1f2dcba99f6ea1257d196ae Mon Sep 17 00:00:00 2001 From: Kirill Ivlev Date: Wed, 27 Nov 2024 13:38:18 +0400 Subject: [PATCH] TGD-52 --- .../admin-testing.component.html | 1 + .../admin-testing/admin-testing.component.ts | 4 +++ .../answer-notification.component.html | 6 +++-- .../answer-notification.component.ts | 25 ++++++++++--------- src/app/services/testing-api.service.ts | 4 +++ 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/app/admin/admin-testing/admin-testing.component.html b/src/app/admin/admin-testing/admin-testing.component.html index 9b9c020..0075a22 100644 --- a/src/app/admin/admin-testing/admin-testing.component.html +++ b/src/app/admin/admin-testing/admin-testing.component.html @@ -5,6 +5,7 @@

Game

+

Versus

diff --git a/src/app/admin/admin-testing/admin-testing.component.ts b/src/app/admin/admin-testing/admin-testing.component.ts index d3f56fa..dcec8de 100644 --- a/src/app/admin/admin-testing/admin-testing.component.ts +++ b/src/app/admin/admin-testing/admin-testing.component.ts @@ -53,4 +53,8 @@ export class AdminTestingComponent implements OnInit, OnDestroy { simulateEndGamePoints() { this.testingApiService.simulateEndGamePoints().pipe(takeUntil(this.destroyed$)).subscribe(r => console.log(r)); } + + simulateValidAnswer() { + this.testingApiService.simulateValidAnswer().pipe(takeUntil(this.destroyed$)).subscribe(r => console.log(r)); + } } diff --git a/src/app/components/answer-notification/answer-notification.component.html b/src/app/components/answer-notification/answer-notification.component.html index 2c8d376..5474eca 100644 --- a/src/app/components/answer-notification/answer-notification.component.html +++ b/src/app/components/answer-notification/answer-notification.component.html @@ -3,8 +3,10 @@

🎉 Ура, правильный ответ!

❌ А вот и нет! ❌

-
- +
+ + +

выйграл наказание

diff --git a/src/app/components/answer-notification/answer-notification.component.ts b/src/app/components/answer-notification/answer-notification.component.ts index dc32863..eebb819 100644 --- a/src/app/components/answer-notification/answer-notification.component.ts +++ b/src/app/components/answer-notification/answer-notification.component.ts @@ -51,11 +51,10 @@ import { VoiceService } from "../../services/voice.service"; export class AnswerNotificationComponent implements OnInit, OnDestroy { isShown = false; answerIsValid = false; - participant: Participant; - timer: Observable; countdown = 10; showCountdown = false; announceAudio = true; + participants: Participant[] = []; audioSrc: string; private destroyed$ = new Subject(); @@ -68,20 +67,21 @@ export class AnswerNotificationComponent implements OnInit, OnDestroy { takeUntil(this.destroyed$), map(e => e.data) ).subscribe(d => this.showNotification(d.telegramId, false, d.validAnswer, null)); - this.eventService.scoreChangedEvent.pipe( - takeUntil(this.destroyed$), - map(e => e.data), - ).subscribe(e => { - if(e.telegramId === this.participant.telegramId) { - this.participant.score = e.newScore - } - }); + // this.eventService.scoreChangedEvent.pipe( + // takeUntil(this.destroyed$), + // map(e => e.data), + // ).subscribe(e => { + // if(e.telegramId === this.participant.telegramId) { + // this.participant.score = e.newScore + // } + // }); } showNotification(telegramId: number, validAnswer: boolean, validAnswerValue: string, note: string|null) { - this.countdown = validAnswer ? 10 : 5; + console.log(`showNotification`); this.apiService.getParticipant(telegramId).subscribe(p => { - this.participant = p; + this.countdown = validAnswer ? 10 : 5; + this.participants.push(p); this.isShown = true; this.answerIsValid = validAnswer; const template = validAnswer ? 'announce-valid' : 'announce-invalid'; @@ -107,6 +107,7 @@ export class AnswerNotificationComponent implements OnInit, OnDestroy { this.announceAudio = false; this.countdown = 10; this.apiService.continueGame().subscribe(r => console.log(r)); + this.participants = []; } ngOnInit(): void { diff --git a/src/app/services/testing-api.service.ts b/src/app/services/testing-api.service.ts index c723891..00290f5 100644 --- a/src/app/services/testing-api.service.ts +++ b/src/app/services/testing-api.service.ts @@ -28,4 +28,8 @@ export class TestingApiService { simulateEndGamePoints() { return this.httpClient.post(`${API_URL}/quiz/calculate-endgame-extrapoints`, {}) } + + simulateValidAnswer() { + return this.httpClient.post(`${API_URL}/game/simulate-valid-answer`, {}); + } } -- 2.45.2