Files
NowChess-Frontend/src/app/models/game.models.ts
T
2026-04-17 23:20:16 +02:00

72 lines
1.2 KiB
TypeScript

export type GameTurn = 'white' | 'black';
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;
}
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;