UNPKG

react-chessboard-expandable

Version:

A fork of the react-chessboard library to support an expandable chessboard

77 lines (76 loc) 2.13 kB
export declare const NON_EXISTENT_SQUARE = "E"; export declare const EMPTY_SQUARE = "e"; export declare const ANIMATION_DURATION = 300; export type Square = { piece: string; rank: string; file: string; }; export type Row = Square[]; export type Col = Square[]; export type Idx = { row: number; col: number; }; export type BoardState = { rows: Row[]; locationToIdx: { [key: string]: Idx; }; locationToUnitSqIdxs: { [key: string]: Idx[]; }; }; type AddUnit = { x: number; y: number; }; export interface BoardStateInterface { getNumRows(): number; getNumCols(): number; getSquare(row: number, col: number): Square; getPiece(location: string): string; isLocationNonExistent(location: string): boolean; getBoard(): BoardState; getUnitSqIdxs(location: string): { row: number; col: number; }[]; getLocationIdx(location: string): { row: number; col: number; }; getDiff(): { added: { [key: string]: string; }; removed: { [key: string]: string; }; }; getIsWaitingForAnimation(): boolean; setManualDrop(wasManualDrop: boolean): void; movePiece(from: string, to: string, piece: string): void; materializeUnit(location: string): void; } /** * Assumption about modifiedFen string: each row should have equal number of * squares. Ideally this should be handled here but to make life easier for now * I want the provider of modifiedFen to handle this. * * Maybe I will handle it here in the future. */ export declare function useBoardState(modifiedFen: string, horizontalExtendLimit: number, verticalExtendLimit: number, horizontalAddUnit: AddUnit, verticalAddUnit: AddUnit): BoardStateInterface; export declare function getDifferences(currPieceMap: { [key: string]: string; }, newPieceMap: { [key: string]: string; }): { added: { [key: string]: string; }; removed: { [key: string]: string; }; }; export {};