2024 edition initial

This commit is contained in:
Kirill Ivlev 2024-10-30 23:56:05 +04:00
parent f3977c77a5
commit 54baeb3e5e
7 changed files with 64 additions and 17 deletions

View file

@ -4,7 +4,7 @@
<div class="col-4"> <div class="col-4">
<app-participant-item [participant]="participant" *ngIf="participant" [small]="true"></app-participant-item> <app-participant-item [participant]="participant" *ngIf="participant" [small]="true"></app-participant-item>
</div> </div>
<div class="col-8"> <div class="col-8" *ngIf="action.type !== gameQueueTypes.showresults">
<div *ngIf="action.type === gameQueueTypes.giveOutAPrize"> <div *ngIf="action.type === gameQueueTypes.giveOutAPrize">
<h1 class="animate__flip animate__animated">Ура, приз!</h1> <h1 class="animate__flip animate__animated">Ура, приз!</h1>
<audio src="assets/sfx/prize.mp3" autoplay></audio> <audio src="assets/sfx/prize.mp3" autoplay></audio>
@ -29,10 +29,9 @@
</div> </div>
</div> </div>
<div class="col-8" *ngIf="action.type === gameQueueTypes.showresults">
Question results
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -16,7 +16,7 @@ import { PrizeDto } from "../../../types/prize.dto";
export class GameQueueComponent implements OnInit { export class GameQueueComponent implements OnInit {
@Input() action: EventGameQueue; @Input() action: EventGameQueue;
readonly gameQueueTypes = QueueTypes readonly gameQueueTypes = QueueTypes
participant: Participant; participant: Participant | null;
destroyed$ = new Subject<void>(); destroyed$ = new Subject<void>();
penalty = ''; penalty = '';
countdown: number; countdown: number;
@ -31,11 +31,14 @@ export class GameQueueComponent implements OnInit {
constructor(private apiService: ApiService) { } constructor(private apiService: ApiService) { }
ngOnInit(): void { ngOnInit(): void {
if(this.action.target) {
this.apiService.getParticipant(this.action.target).pipe( this.apiService.getParticipant(this.action.target).pipe(
takeUntil(this.destroyed$) takeUntil(this.destroyed$)
).subscribe(e => { ).subscribe(e => {
this.participant = e; this.participant = e;
}); });
}
if(this.action.type === this.gameQueueTypes.penalty) { if(this.action.type === this.gameQueueTypes.penalty) {
this.getPenalty(); this.getPenalty();
} }
@ -98,10 +101,13 @@ export class GameQueueComponent implements OnInit {
} }
private getPrize() { private getPrize() {
if(!this.participant === null) {
return;
}
this.apiService.getPrize().pipe(takeUntil(this.destroyed$)).subscribe((r) => { this.apiService.getPrize().pipe(takeUntil(this.destroyed$)).subscribe((r) => {
this.prize = r; this.prize = r;
this.showPrize = true; this.showPrize = true;
this.prizeAudioSrc = getAudioPath(`Поздравляю, ${this.participant.name} получает ${this.prize.name}`); this.prizeAudioSrc = getAudioPath(`Поздравляю, ${this.participant?.name} получает ${this.prize.name}`);
}); });
} }
} }

View file

@ -1,10 +1,10 @@
<div class="container"> <div class="container">
<section *ngIf="question"> <section *ngIf="question">
<div class="question-container"> <div class="question-container">
<h1 class="question-number mt-4"> <h1 class="question-number ">
Вопрос Вопрос <button type="button" class="btn" (click)="continueGame()">next</button>
</h1> </h1>
<h1 class="question-text mt-4"> <h1 class="question-text ">
<!-- <audio *ngIf="audioSrc" [src]="audioSrc" autoplay></audio>--> <!-- <audio *ngIf="audioSrc" [src]="audioSrc" autoplay></audio>-->
{{ question.text }} {{ question.text }}
</h1> </h1>
@ -15,7 +15,14 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row row-cols-md-2">
<div class="col">
</div> </div>
</div>
</div>
</section> </section>
</div> </div>
<div class="countdown" [ngClass]="{ 'warn': countdown < 6 }">
<span *ngIf="countdown >= 0">{{ countdown }} </span>
</div>

View file

@ -25,8 +25,7 @@ section {
margin: 15px; margin: 15px;
background: $yellow_gradient; background: $yellow_gradient;
font-size: 1.5em; font-size: 1.5em;
padding: 10px; padding: 20px 10px 10px;
padding-top: 20px;
border-radius: 23px; border-radius: 23px;
p { p {
text-align: center; text-align: center;
@ -34,3 +33,23 @@ section {
} }
} }
} }
.countdown {
&.warn {
color: $thg_red;
//background-color: $thg_black;
transition: color 2000ms linear, font-size 5000ms ease;
border-radius: 10px;
font-size: 3em;
}
min-width: 40px;
position: absolute;
bottom: 50px;
right: 20px;
z-index: 1000;
span {
font-size: 3em;
font-weight: bold;
}
color: $thg_brown;
}

View file

@ -15,6 +15,8 @@ export class QuestionComponent implements OnInit, OnDestroy {
@Input() question: Question; @Input() question: Question;
destroyed$ = new Subject<void>(); destroyed$ = new Subject<void>();
private questionSubscription: Subscription; private questionSubscription: Subscription;
countdown = 0;
readonly countDownTimer =20;
constructor(private apiService:ApiService, private eventService: EventService, private voiceService: VoiceService) { } constructor(private apiService:ApiService, private eventService: EventService, private voiceService: VoiceService) { }
@ -24,12 +26,25 @@ export class QuestionComponent implements OnInit, OnDestroy {
return; return;
} }
setTimeout(() => this.getQuestion(), 3000); setTimeout(() => this.getQuestion(), 3000);
this.countdown = this.countDownTimer;
setInterval(() => {
console.log(`question countdown`);
this.countdown--;
}, 1000)
this.questionSubscription = this.eventService.questionChangedEvent.subscribe(() =>{ this.questionSubscription = this.eventService.questionChangedEvent.subscribe(() =>{
this.getQuestion(); this.getQuestion();
this.countdown = 20;
}); });
} }
continueGame() {
this.apiService.continueGame().subscribe((r) => {
console.log(r);
});
}
getQuestion() { getQuestion() {
this.apiService.getQuestion().pipe( this.apiService.getQuestion().pipe(
takeUntil(this.destroyed$) takeUntil(this.destroyed$)

View file

@ -114,7 +114,7 @@ export class OnboardingComponent implements OnInit, OnDestroy {
} }
ngOnDestroy(): void { ngOnDestroy(): void {
this.destroyed$.complete(); this.destroyed$.complete();
this.voiceSubscription.unsubscribe(); this.voiceSubscription?.unsubscribe();
} }
shakeCard(card: ElementRef) { shakeCard(card: ElementRef) {

View file

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