This commit is contained in:
Kirill Ivlev 2024-11-28 01:31:02 +04:00
parent 5dd911fb01
commit ad965cfd6a
12 changed files with 37 additions and 16 deletions

View file

@ -7,7 +7,7 @@ import { ActivatedRoute, Router } from "@angular/router";
import { filter, map, takeUntil } from "rxjs/operators";
import { ToastService } from "./toast.service";
import { VoiceService } from "./services/voice.service";
import { Subject } from "rxjs";
import {delay, delayWhen, Subject} from "rxjs";
import { getAudioPath } from "./helper/tts.helper";
import {animate, keyframes, style, transition, trigger} from "@angular/animations";
import {environment} from "../environments/environment";
@ -53,9 +53,8 @@ export class AppComponent implements OnInit, OnDestroy {
console.log(data);
this.eventService.emit(data);
});
this.apiService.getAppState('main').subscribe((result) => {
if(this.router.url.indexOf('admin') === -1) {
console.log(this.router.url);
this.apiService.getAppState('main').pipe(takeUntil(this.destroyed),delay(300)).subscribe((result) => {
if(this.router.url.indexOf('admin') === -1 || window.location.href.indexOf('admin') === -1) {
this.router.navigate([`/${result.value}`]).then(() => {
console.log(`navigated to ${result.value}`);
})

View file

@ -3,7 +3,7 @@
<div class="d-block justify-content-centers">
<h1 *ngIf="answerIsValid">🎉 Ура, правильный ответ!</h1>
<h1 *ngIf="!answerIsValid">А вот и нет! ❌</h1>
<div class="d-flex align-items-center justify-content-center flex-wrap">
<div class="d-flex align-items-center justify-content-center flex-wrap" *ngIf="this.participants.length > 0">
<ng-container *ngFor="let participant of participants" >
<app-participant-item [participant]="participant"></app-participant-item>
</ng-container>

View file

@ -1,6 +1,6 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ApiService } from "../../services/api.service";
import { interval, Observable, Subject } from "rxjs";
import {concatMap, interval, Observable, Subject} from "rxjs";
import { EventService } from "../../services/event.service";
import { filter, map, take, takeUntil, tap } from "rxjs/operators";
import { Participant } from "../../../types/participant";
@ -57,7 +57,6 @@ export class AnswerNotificationComponent implements OnInit, OnDestroy {
participants: Participant[] = [];
audioSrc: string;
private destroyed$ = new Subject<void>();
constructor(private apiService: ApiService, private eventService: EventService, private voiceService: VoiceService) {
this.eventService.answerReceivedEvent.pipe(
takeUntil(this.destroyed$),
@ -75,6 +74,8 @@ export class AnswerNotificationComponent implements OnInit, OnDestroy {
// this.participant.score = e.newScore
// }
// });
}
showNotification(telegramId: number, validAnswer: boolean, validAnswerValue: string, note: string|null) {
@ -89,7 +90,10 @@ export class AnswerNotificationComponent implements OnInit, OnDestroy {
templateData['user'] = p.name;
templateData['answer'] = validAnswerValue;
templateData['user-genitive'] = p.properties.genitive;
this.voiceService.playAudio(getAudioPathWithTemplate(template, '', templateData));
if(this.participants.length === 1) {
this.voiceService.playAudio(getAudioPathWithTemplate(template, '', templateData));
}
//this.voiceService.playAudio(getAudioPathWithTemplate(template, '', templateData));
this.voiceService.audioEndedSubject.pipe(takeUntil(this.destroyed$), take(1)).subscribe(r => {
if (note && validAnswer) {
this.voiceService.playAudio(getAudioPath(note))
@ -101,13 +105,14 @@ export class AnswerNotificationComponent implements OnInit, OnDestroy {
}
countdownCompleted() {
this.participants = [];
console.log(`countdown-completed`);
this.showCountdown = false;
this.isShown = false;
this.announceAudio = false;
this.countdown = 10;
this.apiService.continueGame().subscribe(r => console.log(r));
this.participants = [];
// this.apiService.continueGame().subscribe(r => console.log(r));
}
ngOnInit(): void {

View file

@ -59,3 +59,6 @@
</div>
</div>
</div>
<div class="versus-container" *ngIf="action && action.type === gameQueueTypes.versus">
</div>

View file

@ -50,4 +50,11 @@ h1,h3 {
animation: results 3s 1;
background-color: $thg_yellow;
color: black;
}
.versus-container {
position: absolute;
width: 100%;
height: 100vh;
background-color: $thg_red;
}

View file

@ -3,7 +3,7 @@ import { EventGameQueue, QueueTypes } from "../../../types/server-event";
import { Participant } from "../../../types/participant";
import { ApiService } from "../../services/api.service";
import { Subject } from "rxjs";
import {map, takeUntil} from "rxjs/operators";
import {map, take, takeUntil} from "rxjs/operators";
import { Question } from "../../../types/question";
import { getAudioPath } from "../../helper/tts.helper";
import { PrizeDto } from "../../../types/prize.dto";

View file

@ -1,5 +1,5 @@
<div class="card rounded m-3 animate__animated" [ngClass]="{ 'small': small, 'shadow': shadow, 'transparent': transparent, 'banned': banned, 'animate__flipInY': small }">
<figure class="p-1" *ngIf="participant">
<div *ngIf="participant" class="card rounded m-3 animate__animated" [ngClass]="{ 'small': small, 'shadow': shadow, 'transparent': transparent, 'banned': banned, 'animate__flipInY': small }">
<figure class="p-1">
<img [src]="getImageUrl()" class="participant-photo img-fluid">
</figure>
<div class="card-title">

View file

@ -13,6 +13,7 @@
.transparent {
background: inherit;
max-width: 200px;
}
figure {
@ -66,7 +67,7 @@ figure {
}
.big {
font-size: 7em;
font-size: 3em;
color: $thg_green;
transition-delay: 2s;

View file

@ -93,6 +93,11 @@ export class ApiService {
return this.httpClient.post(`${environment.API_URL}/quiz/proceed`, {});
}
questionTimeout() {
console.log(`continue game`);
return this.httpClient.post(`${environment.API_URL}/quiz/timeout`, {});
}
markQueueAsCompleted(_id: string) {
return this.httpClient.post(`${environment.API_URL}/game/${_id}/complete`, {});
}

View file

@ -54,7 +54,7 @@
<img src="../../../assets/cards/BanPlayer.png" class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Заблокировать игрока</h5>
<p class="card-text">Запрещает игроку давать ответы в следующих двух раундах</p>
<p class="card-text">Запрещает игроку давать ответы в случайном количестве раундов</p>
</div>
</div>
</div>

View file

@ -60,7 +60,7 @@ export class OnboardingComponent implements OnInit, OnDestroy {
this.shakeCard(this.luckyCardEl);
}},
{
text: 'Карту бана можно сыграть на любого игрока (даже себя), чтобы отправить его на пару ходов во Владикавказ. Игрок не сможет участвовать в игре в течение двух раундов',
text: 'Карту бана можно сыграть на любого игрока (даже себя), чтобы отправить его на пару ходов во Владикавказ. Игрок не сможет участвовать в случайном количестве раундов',
action: () => {
this.shakeCard(this.banPlayerEl);
}

View file

@ -7,6 +7,7 @@ export enum QueueTypes {
playExtraCard = 'play_extra_card',
screpa = 'screpa',
showresults = 'show_results',
versus = 'versus',
}
export interface EventPhotosUpdated {