UNPKG

@chess-fu/chess-game

Version:
73 lines (72 loc) 2.03 kB
import { Move, MoveOptions, Offset, Color, GameResult } from './chessTypes'; declare type MoveData = Move & Offset & { restoreFEN?: string; }; export declare class ChessGame { private _headers; private _history; private _board; private _turn; private _enpass; private _halfmoveClock; private _moveNumber; private _whiteKing; private _blackKing; private _castles; private _cacheValid; private _gameResult; private _checked; private _noValidMoves; constructor(fen?: string); private init; load(fen?: string): void; loadPgn(pgnGame: string): void; private restoreFen; toString(): string; fen(): string; pgn(options?: { newline_char: string; max_width: number; }): string; pgnHeaders(keys: string[], headers: any): string[]; squares(): string[]; turn(): Color; header(...tagPairs: string[]): { [key: string]: string; }; history(options?: any): Move[]; get(square: string): string | null; set(square: string, piece?: string): void; remove(square: string): void; private updated; private updateCachedState; undo(): Move | undefined; move(move: Move | string): Move; private moveToSAN; private performMove; private canMoveTo; private getMovesBySquare; private getCastleMoves; private getCastle; private getMovesFrom; isValidAttack(move: MoveData, offset: Offset, color: Color): boolean; private isSquareAttacked; moves(options?: MoveOptions): Move[]; private getMoves; private disambiguateFrom; private testForCheck; private hasValidMoves; getResult(): GameResult; private assertOngoing; isInCheck(): boolean; isCheckmate(): boolean; isStalemate(): boolean; isAutomaticDraw(): boolean; hasThreefoldRepetition(): boolean; hasExceededFiftyMoveRule(): boolean; canDraw(): boolean; setDraw(): void; isDraw(): boolean; isOngoing(): boolean; } export default ChessGame;