fix: build errors
This commit is contained in:
@@ -1,48 +1,48 @@
|
|||||||
export interface BotRef {
|
export interface TournamentClock {
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Clock {
|
|
||||||
limit: number;
|
limit: number;
|
||||||
increment: number;
|
increment: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Variant {
|
export interface TournamentVariant {
|
||||||
key: string;
|
key: string;
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ResultDto {
|
export interface TournamentBotRef {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TournamentResult {
|
||||||
rank: number;
|
rank: number;
|
||||||
points: number;
|
points: number;
|
||||||
tieBreak: number;
|
tieBreak: number;
|
||||||
bot: BotRef;
|
bot: TournamentBotRef;
|
||||||
nbGames: number;
|
nbGames: number;
|
||||||
wins: number;
|
wins: number;
|
||||||
draws: number;
|
draws: number;
|
||||||
losses: number;
|
losses: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Standing {
|
export interface TournamentStanding {
|
||||||
page: number;
|
page: number;
|
||||||
players: ResultDto[];
|
players: TournamentResult[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Tournament {
|
export interface Tournament {
|
||||||
id: string;
|
id: string;
|
||||||
fullName: string;
|
fullName: string;
|
||||||
clock: Clock;
|
clock: TournamentClock;
|
||||||
variant: Variant;
|
variant: TournamentVariant;
|
||||||
rated: boolean;
|
rated: boolean;
|
||||||
nbPlayers: number;
|
nbPlayers: number;
|
||||||
nbRounds: number;
|
nbRounds: number;
|
||||||
createdBy: string;
|
createdBy: string;
|
||||||
startsAt: string | null;
|
startsAt: string | null;
|
||||||
status: string;
|
status: 'created' | 'started' | 'finished';
|
||||||
round: number;
|
round: number;
|
||||||
standing: Standing;
|
standing: TournamentStanding;
|
||||||
winner: BotRef | null;
|
winner: TournamentBotRef | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TournamentList {
|
export interface TournamentList {
|
||||||
@@ -51,16 +51,16 @@ export interface TournamentList {
|
|||||||
finished: Tournament[];
|
finished: Tournament[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Pairing {
|
export interface TournamentPairing {
|
||||||
id: string;
|
id: string;
|
||||||
round: number;
|
round: number;
|
||||||
white: BotRef | null;
|
white: TournamentBotRef | null;
|
||||||
black: BotRef;
|
black: TournamentBotRef;
|
||||||
gameId: string | null;
|
gameId: string | null;
|
||||||
winner: string | null;
|
winner: 'white' | 'black' | 'draw' | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RoundPairings {
|
export interface RoundPairings {
|
||||||
round: number;
|
round: number;
|
||||||
pairings: Pairing[];
|
pairings: TournamentPairing[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { Injectable, inject } from '@angular/core';
|
import { Injectable, inject } from '@angular/core';
|
||||||
import { HttpClient } from '@angular/common/http';
|
import { HttpClient } from '@angular/common/http';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable, map } from 'rxjs';
|
||||||
import { Bot, BotWithToken } from '../models/bot.models';
|
import { Bot, BotWithToken } from '../models/bot.models';
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class BotService {
|
export class BotService {
|
||||||
private readonly http = inject(HttpClient);
|
private readonly http = inject(HttpClient);
|
||||||
private readonly base = '/api/account/official-bots';
|
private readonly base = '/api/account/bots';
|
||||||
|
|
||||||
list(): Observable<Bot[]> {
|
list(): Observable<Bot[]> {
|
||||||
return this.http.get<Bot[]>(this.base);
|
return this.http.get<Bot[]>(this.base);
|
||||||
@@ -16,6 +16,11 @@ export class BotService {
|
|||||||
return this.http.post<BotWithToken>(this.base, { name });
|
return this.http.post<BotWithToken>(this.base, { name });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rotateToken(botId: string): Observable<string> {
|
||||||
|
return this.http.post<{ token: string }>(`${this.base}/${botId}/rotate-token`, null)
|
||||||
|
.pipe(map(r => r.token));
|
||||||
|
}
|
||||||
|
|
||||||
delete(botId: string): Observable<void> {
|
delete(botId: string): Observable<void> {
|
||||||
return this.http.delete<void>(`${this.base}/${botId}`);
|
return this.http.delete<void>(`${this.base}/${botId}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,10 @@ export class TournamentService {
|
|||||||
return this.http.post<Tournament>(`${this.base}/${id}/start`, null);
|
return this.http.post<Tournament>(`${this.base}/${id}/start`, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
join(id: string, botId: string, botName: string): Observable<void> {
|
joinWithBotToken(id: string, botToken: string): Observable<void> {
|
||||||
return this.http.post<void>(`${this.base}/${id}/join`, { botId, botName });
|
return this.http.post<void>(`${this.base}/${id}/join`, null, {
|
||||||
|
headers: new HttpHeaders({ Authorization: `Bearer ${botToken}` })
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
roundPairings(id: string, round: number): Observable<RoundPairings> {
|
roundPairings(id: string, round: number): Observable<RoundPairings> {
|
||||||
|
|||||||
Reference in New Issue
Block a user