Files
NowChess-Frontend/src/app/models/game.models.ts
T
shosho996 c02414ea40 fix: NCWF-2 bugs and desing fixes (#7)
Co-authored-by: Lala, Shahd <Shahd.Lala@sybit.de>
Reviewed-on: #7
2026-05-15 02:16:43 +02:00

78 lines
1.3 KiB
TypeScript

export type GameTurn = 'white' | 'black';
export interface ClockState {
whiteRemainingMs: number;
blackRemainingMs: number;
}
export type GameStatus =
| 'started'
| 'check'
| 'checkmate'
| 'stalemate'
| 'resign'
| 'draw'
| 'drawOffered'
| 'fiftyMoveAvailable'
| 'promotionPending'
| 'insufficientMaterial';
export interface PlayerInfo {
id: string;
displayName: string;
}
export interface GameState {
fen: string;
pgn: string;
turn: GameTurn;
status: GameStatus;
winner?: GameTurn | null;
moves: string[];
undoAvailable: boolean;
redoAvailable: boolean;
clock: ClockState | null;
}
export interface GameFull {
gameId: string;
white: PlayerInfo;
black: PlayerInfo;
state: GameState;
}
export interface LegalMove {
from: string;
to: string;
uci: string;
moveType: string;
promotion?: 'queen' | 'rook' | 'bishop' | 'knight' | null;
}
export interface LegalMovesResponse {
moves: LegalMove[];
}
export interface ApiError {
code: string;
message: string;
field?: string | null;
}
export interface GameFullEvent {
type: 'gameFull';
game: GameFull;
}
export interface GameStateEvent {
type: 'gameState';
state: GameState;
}
export interface ErrorEvent {
type: 'error';
error: ApiError;
}
export type GameStreamEvent = GameFullEvent | GameStateEvent | ErrorEvent;