versus implementation
This commit is contained in:
parent
afabd52e02
commit
9462031af5
18 changed files with 227 additions and 39 deletions
|
|
@ -1,6 +1,12 @@
|
||||||
<div class="game-testing m-2" *ngIf="!prodMode">
|
<div class="game-testing m-2" *ngIf="!prodMode">
|
||||||
<h3>Game testing menu</h3>
|
<h3>Game testing menu</h3>
|
||||||
|
<h4>Players</h4>
|
||||||
|
<button class="btn btn-danger" (click)="resetAllPlayersScore()">Reset score to 0</button>
|
||||||
|
<h4>Game</h4>
|
||||||
|
<button class="btn btn-danger" (click)="clearGameQueue()">Clear queue</button>
|
||||||
|
<h4>Versus</h4>
|
||||||
<button class="btn btn-danger" (click)="simulateVersus()">Begin versus</button>
|
<button class="btn btn-danger" (click)="simulateVersus()">Begin versus</button>
|
||||||
|
<button class="btn btn-danger" (click)="resetAllVersusTasksAsIncompleted()">Mark all as uncompleted</button>
|
||||||
<button class="btn btn-danger" disabled>Stop versus</button>
|
<button class="btn btn-danger" disabled>Stop versus</button>
|
||||||
<button class="btn btn-danger" disabled>Simulate endgame points</button>
|
<button class="btn btn-danger" disabled>Simulate endgame points</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -37,4 +37,16 @@ export class AdminTestingComponent implements OnInit, OnDestroy {
|
||||||
simulateVersus() {
|
simulateVersus() {
|
||||||
this.testingApiService.simulateVersus().pipe(takeUntil(this.destroyed$)).subscribe((r) => console.log(r));
|
this.testingApiService.simulateVersus().pipe(takeUntil(this.destroyed$)).subscribe((r) => console.log(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetAllVersusTasksAsIncompleted() {
|
||||||
|
this.testingApiService.resetAllVersusTasksAsIncompleted().pipe(takeUntil(this.destroyed$)).subscribe((r) => console.log(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
resetAllPlayersScore() {
|
||||||
|
this.testingApiService.resetAllPlayersScore().pipe(takeUntil(this.destroyed$)).subscribe(r => console.log(r));
|
||||||
|
}
|
||||||
|
|
||||||
|
clearGameQueue() {
|
||||||
|
this.testingApiService.clearGameQueue().pipe(takeUntil(this.destroyed$)).subscribe((r => console.log(r)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,3 +3,8 @@
|
||||||
<div>tg: {{ gameQueue.type }}</div>
|
<div>tg: {{ gameQueue.type }}</div>
|
||||||
<button class="btn btn-dark" (click)="markAsCompleted(gameQueue._id)">complete</button>
|
<button class="btn btn-dark" (click)="markAsCompleted(gameQueue._id)">complete</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="versusData">
|
||||||
|
<h1>Who won</h1>
|
||||||
|
<button class="btn btn-dark m-2" (click)="versusWon(versusData.player1)">{{ versusData.player1name}}</button>
|
||||||
|
<button class="btn btn-dark m-2" (click)="versusWon(versusData.player2)">{{ versusData.player2name}}</button>
|
||||||
|
</div>
|
||||||
|
|
@ -2,7 +2,7 @@ import { Component, OnDestroy, OnInit } from '@angular/core';
|
||||||
import { EventService } from "../../../services/event.service";
|
import { EventService } from "../../../services/event.service";
|
||||||
import { Subject } from "rxjs";
|
import { Subject } from "rxjs";
|
||||||
import { map, takeUntil } from "rxjs/operators";
|
import { map, takeUntil } from "rxjs/operators";
|
||||||
import { EventGameQueue, QueueTypes } from "../../../../types/server-event";
|
import {EventGameQueue, QueueTypes, VersusBeginEvent} from "../../../../types/server-event";
|
||||||
import { ApiService } from "../../../services/api.service";
|
import { ApiService } from "../../../services/api.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
@ -14,7 +14,7 @@ export class QueueActionsComponent implements OnInit, OnDestroy {
|
||||||
destroyed$ = new Subject<void>()
|
destroyed$ = new Subject<void>()
|
||||||
constructor(private eventService: EventService, private apiService: ApiService) { }
|
constructor(private eventService: EventService, private apiService: ApiService) { }
|
||||||
gameQueue: EventGameQueue | null;
|
gameQueue: EventGameQueue | null;
|
||||||
|
versusData: VersusBeginEvent| null = null;
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.eventService.gameQueueEvent.pipe(
|
this.eventService.gameQueueEvent.pipe(
|
||||||
takeUntil(this.destroyed$),
|
takeUntil(this.destroyed$),
|
||||||
|
|
@ -22,7 +22,17 @@ export class QueueActionsComponent implements OnInit, OnDestroy {
|
||||||
).subscribe(e => {
|
).subscribe(e => {
|
||||||
this.gameQueue = e;
|
this.gameQueue = e;
|
||||||
});
|
});
|
||||||
|
this.setVersusHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setVersusHandler() {
|
||||||
|
this.eventService.versusBegin.pipe(takeUntil(this.destroyed$)).subscribe((r) => {
|
||||||
|
this.versusData = r.data;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.destroyed$.complete();
|
this.destroyed$.complete();
|
||||||
}
|
}
|
||||||
|
|
@ -32,4 +42,10 @@ export class QueueActionsComponent implements OnInit, OnDestroy {
|
||||||
// this.gameQueue = null;
|
// this.gameQueue = null;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
versusWon(playerId: number) {
|
||||||
|
this.apiService.completeVersus(playerId).subscribe(r => {
|
||||||
|
this.versusData = null;
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<app-versus *ngIf="versusInProgress" [player1]="versusData.player1" [player2]="versusData.player2">
|
<app-versus *ngIf="versusData" [@enterAnimation] [player1]="versusData.player1" [player2]="versusData.player2">
|
||||||
|
|
||||||
</app-versus>
|
</app-versus>
|
||||||
<app-toast>
|
<app-toast>
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,31 @@ import { ToastService } from "./toast.service";
|
||||||
import { VoiceService } from "./services/voice.service";
|
import { VoiceService } from "./services/voice.service";
|
||||||
import { Subject } from "rxjs";
|
import { Subject } from "rxjs";
|
||||||
import { getAudioPath } from "./helper/tts.helper";
|
import { getAudioPath } from "./helper/tts.helper";
|
||||||
|
import {animate, keyframes, style, transition, trigger} from "@angular/animations";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.scss']
|
styleUrls: ['./app.component.scss'],
|
||||||
|
animations: [
|
||||||
|
trigger(
|
||||||
|
'enterAnimation', [
|
||||||
|
transition(':enter', [
|
||||||
|
style({transform: 'translateX(100%)', opacity: 0}),
|
||||||
|
animate('500ms', style({transform: 'translateX(0)', opacity: 1}))
|
||||||
|
]),
|
||||||
|
transition(':leave', [
|
||||||
|
style({transform: 'translateX(0)', opacity: 1}),
|
||||||
|
animate('2000ms', style({transform: 'translateX(100%)', opacity: 0}))
|
||||||
|
])
|
||||||
|
]
|
||||||
|
)]
|
||||||
})
|
})
|
||||||
export class AppComponent implements OnInit, OnDestroy {
|
export class AppComponent implements OnInit, OnDestroy {
|
||||||
title = 'thanksgiving';
|
title = 'thanksgiving';
|
||||||
connection = io(WEBSOCK_URL, { transports: ['websocket']});
|
connection = io(WEBSOCK_URL, { transports: ['websocket']});
|
||||||
destroyed = new Subject<void>();
|
destroyed = new Subject<void>();
|
||||||
versusInProgress = false;
|
versusData: VersusBeginEvent|null = null;
|
||||||
versusData: VersusBeginEvent;
|
|
||||||
audioSrc: string;
|
audioSrc: string;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
|
@ -70,12 +83,14 @@ export class AppComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private setupVersusHandler() {
|
private setupVersusHandler() {
|
||||||
console.log(this.routeSnapshot.snapshot.url);
|
this.eventService.versusBegin.pipe(takeUntil(this.destroyed)).subscribe(r => {
|
||||||
this.eventService.versusBegin.pipe(takeUntil(this.destroyed)).subscribe(r => {
|
if (this.router.url.indexOf('admin') === -1) {
|
||||||
if(this.router.url.indexOf('admin') === -1) {
|
this.versusData = r.data;
|
||||||
this.versusInProgress = true;
|
}
|
||||||
this.versusData = r.data;
|
})
|
||||||
}
|
this.eventService.versusEnd.pipe(takeUntil(this.destroyed)).subscribe((r) => {
|
||||||
})
|
console.log(r);
|
||||||
}
|
this.versusData = null;
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
.cards-history {
|
.cards-history {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
z-index: 20000;
|
z-index: 1000;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
max-height: 70px;
|
max-height: 70px;
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<img [src]="getImageUrl()" class="participant-photo img-fluid">
|
<img [src]="getImageUrl()" class="participant-photo img-fluid">
|
||||||
</figure>
|
</figure>
|
||||||
<div class="card-title">
|
<div class="card-title">
|
||||||
{{ participant.name }}
|
{{ participant?.name }}
|
||||||
</div>
|
</div>
|
||||||
<div class="content" *ngIf="!small">
|
<div class="content" *ngIf="!small">
|
||||||
<div class="card-subtitle">
|
<div class="card-subtitle">
|
||||||
|
|
|
||||||
|
|
@ -64,13 +64,18 @@ export class ParticipantItemComponent implements OnInit, OnDestroy, OnChanges {
|
||||||
}
|
}
|
||||||
|
|
||||||
getCards() {
|
getCards() {
|
||||||
this.apiService.getCards(this.participant.telegramId).subscribe((r) => {
|
if(this.participant) {
|
||||||
this.cards = r;
|
this.apiService.getCards(this.participant.telegramId).subscribe((r) => {
|
||||||
})
|
this.cards = r;
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getImageUrl() {
|
getImageUrl() {
|
||||||
return `${API_URL}/guests/photo/${this.participant.telegramId}?$t=${this.imgTimestamp}`;
|
if(this.participant) {
|
||||||
|
return `${API_URL}/guests/photo/${this.participant.telegramId}?$t=${this.imgTimestamp}`;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ 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;
|
||||||
|
countdownInterval:ReturnType<typeof setInterval>|null= null;
|
||||||
countdown = 0;
|
countdown = 0;
|
||||||
readonly countDownTimer =20;
|
readonly countDownTimer =20;
|
||||||
|
|
||||||
|
|
@ -31,20 +32,33 @@ export class QuestionComponent implements OnInit, OnDestroy {
|
||||||
this.countdown = -1;
|
this.countdown = -1;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.countdown = this.countDownTimer;
|
this.startCountdown();
|
||||||
setInterval(() => {
|
|
||||||
console.log(`question countdown`);
|
|
||||||
if(this.countdown === 0) {
|
|
||||||
this.continueGame();
|
|
||||||
}
|
|
||||||
this.countdown--;
|
|
||||||
}, 1000)
|
|
||||||
|
|
||||||
this.questionSubscription = this.eventService.questionChangedEvent.subscribe(() =>{
|
this.questionSubscription = this.eventService.questionChangedEvent.subscribe(() =>{
|
||||||
this.getQuestion();
|
this.getQuestion();
|
||||||
this.countdown = 20;
|
this.countdown = 20;
|
||||||
});
|
});
|
||||||
|
this.setUpVersusHandler();
|
||||||
|
}
|
||||||
|
startCountdown() {
|
||||||
|
this.countdown = this.countDownTimer;
|
||||||
|
this.countdownInterval = setInterval(() => {
|
||||||
|
if(this.countdown === 0) {
|
||||||
|
this.continueGame();
|
||||||
|
}
|
||||||
|
this.countdown--;
|
||||||
|
}, 1000)
|
||||||
|
}
|
||||||
|
|
||||||
|
setUpVersusHandler() {
|
||||||
|
this.eventService.versusBegin.pipe(takeUntil(this.destroyed$)).subscribe((r) => {
|
||||||
|
if(this.countdownInterval) {
|
||||||
|
clearInterval(this.countdownInterval);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.eventService.versusBegin.pipe(takeUntil(this.destroyed$)).subscribe((r) => {
|
||||||
|
this.startCountdown();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
continueGame() {
|
continueGame() {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,24 @@
|
||||||
<div class="versus">
|
<div class="versus">
|
||||||
|
|
||||||
<div class="d-flex players">
|
<div class="d-flex players">
|
||||||
<div class="player-one">
|
<div class="player-one" *ngIf=[playersLoaded] >
|
||||||
<app-participant-item [participant]="player1data" [small]="true" [shadow]="false" [transparent]="true">
|
<app-participant-item [participant]="player1data" [small]="true" [shadow]="false" [transparent]="true">
|
||||||
</app-participant-item>
|
</app-participant-item>
|
||||||
</div>
|
</div>
|
||||||
<div class="player-two">
|
<div class="player-two" *ngIf=[playersLoaded]>
|
||||||
<app-participant-item [participant]="player2data" [small]="true" [shadow]="false" [transparent]="true">
|
<app-participant-item [participant]="player2data" [small]="true" [shadow]="false" [transparent]="true">
|
||||||
|
|
||||||
</app-participant-item>
|
</app-participant-item>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="w-100 d-flex justify-content-center " *ngIf="versusData">
|
||||||
|
<div class="task row justify-content-center rounded-5 shadow p-2" >
|
||||||
|
<div class="col-12 text-center">
|
||||||
|
<h1>{{ versusData.text}}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 text-center">
|
||||||
|
<div>{{ versusData.description }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -25,6 +25,26 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes slideInUp {
|
||||||
|
0% {
|
||||||
|
bottom: -100px;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
bottom: 25%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes opacityIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 0.84;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.versus {
|
.versus {
|
||||||
background-color: $thg_brown;
|
background-color: $thg_brown;
|
||||||
|
|
@ -66,7 +86,7 @@
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
animation: slideRight 1s ease forwards;
|
animation: slideRight 2s ease forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Right player area */
|
/* Right player area */
|
||||||
|
|
@ -82,5 +102,15 @@
|
||||||
color: white;
|
color: white;
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
animation: slideLeft 1s ease forwards;
|
animation: slideLeft 2s ease forwards;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.task {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
height: 10%;
|
||||||
|
width: 50%;
|
||||||
|
background-color: white;
|
||||||
|
opacity: 0.84;
|
||||||
|
animation: slideInUp 3s ease forwards, opacityIn 1500ms linear;
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
|
import {Component, Input, OnDestroy, OnInit} from '@angular/core';
|
||||||
import {ApiService} from "../../services/api.service";
|
import {ApiService} from "../../services/api.service";
|
||||||
import {Subject} from "rxjs";
|
import {combineLatest, Subject} from "rxjs";
|
||||||
import {takeUntil} from "rxjs/operators";
|
import {combineAll, takeUntil} from "rxjs/operators";
|
||||||
import {Participant} from "../../../types/participant";
|
import {Participant} from "../../../types/participant";
|
||||||
|
import {VersusItem} from "../../../types/versus-item";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-versus',
|
selector: 'app-versus',
|
||||||
|
|
@ -15,18 +16,35 @@ export class VersusComponent implements OnInit, OnDestroy{
|
||||||
player1data: Participant;
|
player1data: Participant;
|
||||||
player2data: Participant;
|
player2data: Participant;
|
||||||
destroyed$ = new Subject<void>();
|
destroyed$ = new Subject<void>();
|
||||||
|
playersLoaded = false;
|
||||||
|
versusData: VersusItem | null = null;
|
||||||
|
|
||||||
constructor(private apiService: ApiService) {
|
constructor(private apiService: ApiService) {
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.loadPlayersData();
|
this.loadPlayersData();
|
||||||
|
this.loadTask()
|
||||||
}
|
}
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this.destroyed$.complete();
|
this.destroyed$.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPlayersData() {
|
loadPlayersData() {
|
||||||
this.apiService.getParticipant(this.player1).pipe(takeUntil(this.destroyed$)).subscribe((r) => this.player1data = r);
|
const player1Data$ = this.apiService.getParticipant(this.player1);
|
||||||
this.apiService.getParticipant(this.player2).pipe(takeUntil(this.destroyed$)).subscribe((r) => this.player2data = r);
|
const player2Data$ = this.apiService.getParticipant(this.player2);
|
||||||
|
combineLatest([player1Data$,player2Data$]).pipe(takeUntil(this.destroyed$)).subscribe(([d1,d2]) => {
|
||||||
|
this.player1data = d1;
|
||||||
|
this.player2data = d2;
|
||||||
|
this.playersLoaded = true;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
private loadTask() {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.apiService.getVersus().pipe(takeUntil(this.destroyed$)).subscribe((r) => {
|
||||||
|
this.versusData = r;
|
||||||
|
})
|
||||||
|
}, 1500);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,30 @@ import { GameState } from "./gameState";
|
||||||
import { PenaltyDto } from "../../types/penalty.dto";
|
import { PenaltyDto } from "../../types/penalty.dto";
|
||||||
import { PrizeDto } from "../../types/prize.dto";
|
import { PrizeDto } from "../../types/prize.dto";
|
||||||
import {QuestionresultsDto} from "../../types/questionresults.dto";
|
import {QuestionresultsDto} from "../../types/questionresults.dto";
|
||||||
|
import {map} from "rxjs/operators";
|
||||||
|
import {VersusItem} from "../../types/versus-item";
|
||||||
|
|
||||||
export interface FeatureFlagStateDto {
|
export interface FeatureFlagStateDto {
|
||||||
name: string;
|
name: string;
|
||||||
state: boolean;
|
state: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface StateInformationDto<T extends { action: string}> {
|
||||||
|
key: string;
|
||||||
|
value: { key: string; value: T };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface StateInformationVersusDto {
|
||||||
|
action: any;
|
||||||
|
player1: number;
|
||||||
|
player2: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConfigRecordDto {
|
||||||
|
key: string;
|
||||||
|
value: string;
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
|
|
@ -107,4 +125,18 @@ export class ApiService {
|
||||||
setFeatureFlagState(feature: string, state: boolean) {
|
setFeatureFlagState(feature: string, state: boolean) {
|
||||||
return this.httpClient.post<FeatureFlagStateDto>(`${API_URL}/featureflag`, { name: feature, state: state });
|
return this.httpClient.post<FeatureFlagStateDto>(`${API_URL}/featureflag`, { name: feature, state: state });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getStateDetails() {
|
||||||
|
return this.httpClient.get<ConfigRecordDto>(`${API_URL}/game/state-details`);
|
||||||
|
}
|
||||||
|
|
||||||
|
getVersus() {
|
||||||
|
return this.httpClient.get<VersusItem>(`${API_URL}/versus`);
|
||||||
|
}
|
||||||
|
|
||||||
|
completeVersus(winner: number) {
|
||||||
|
return this.httpClient.post(`${API_URL}/versus/complete`, {
|
||||||
|
winner: winner
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ export class EventService {
|
||||||
public userPropertyChanged = new EventEmitter<ServerEvent<UserPropertyChanged>>();
|
public userPropertyChanged = new EventEmitter<ServerEvent<UserPropertyChanged>>();
|
||||||
public featureFlagChanged = new EventEmitter<ServerEvent<void>>()
|
public featureFlagChanged = new EventEmitter<ServerEvent<void>>()
|
||||||
public versusBegin = new EventEmitter<ServerEvent<VersusBeginEvent>>();
|
public versusBegin = new EventEmitter<ServerEvent<VersusBeginEvent>>();
|
||||||
|
public versusEnd = new EventEmitter<ServerEvent<{ winner: number }>>
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
public emit(event: ServerEvent<any>) {
|
public emit(event: ServerEvent<any>) {
|
||||||
|
|
@ -89,6 +90,9 @@ export class EventService {
|
||||||
case "begin_versus":
|
case "begin_versus":
|
||||||
this.versusBegin.emit(event as ServerEvent<VersusBeginEvent>);
|
this.versusBegin.emit(event as ServerEvent<VersusBeginEvent>);
|
||||||
break;
|
break;
|
||||||
|
case "end_versus":
|
||||||
|
this.versusEnd.emit(event as ServerEvent<{winner: number}>);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,18 @@ export class TestingApiService {
|
||||||
constructor(private httpClient: HttpClient) { }
|
constructor(private httpClient: HttpClient) { }
|
||||||
|
|
||||||
public simulateVersus() {
|
public simulateVersus() {
|
||||||
return this.httpClient.post(`${API_URL}/game/simulate-versus`, {});
|
return this.httpClient.post(`${API_URL}/versus/simulate-versus`, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
resetAllVersusTasksAsIncompleted() {
|
||||||
|
return this.httpClient.post(`${API_URL}/versus/reset-all`, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
resetAllPlayersScore() {
|
||||||
|
return this.httpClient.post(`${API_URL}/guests/reset-score`, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
clearGameQueue() {
|
||||||
|
return this.httpClient.post(`${API_URL}/game/clear-queue`, {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@ export interface EventScoreChanged {
|
||||||
export interface VersusBeginEvent {
|
export interface VersusBeginEvent {
|
||||||
player1: number;
|
player1: number;
|
||||||
player2: number;
|
player2: number;
|
||||||
|
player1name: string;
|
||||||
|
player2name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EventGameQueue {
|
export interface EventGameQueue {
|
||||||
|
|
@ -94,5 +96,6 @@ export interface ServerEvent<T> {
|
||||||
| 'user_property_changed'
|
| 'user_property_changed'
|
||||||
| 'feature_flag_changed'
|
| 'feature_flag_changed'
|
||||||
| 'begin_versus'
|
| 'begin_versus'
|
||||||
|
| 'end_versus'
|
||||||
data: T
|
data: T
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
src/types/versus-item.ts
Normal file
6
src/types/versus-item.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
export interface VersusItem {
|
||||||
|
text: string;
|
||||||
|
name: string;
|
||||||
|
completed: boolean;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue