UNPKG

@real_one_chess_king/game-logic

Version:
43 lines (42 loc) 1.61 kB
import { Cell } from "../cell"; import { Turn } from "../turn"; import { Color } from "../color"; import { Piece } from "../piece/piece"; import { PieceType } from "../piece/piece.constants"; import { Action } from "../affect/affect.types"; import { Coordinate } from "../coordinate"; import { BoardMeta } from "./board.types"; /** * Board keeps data about current game position and pieces on the array of cells * It provides methods for manipulation by affects, but not dirrect access to pieces * Always should be filled in by metadata */ export declare class Board { size: number; private squares; private rulesEngine; /** * Metastorage is needed for saving initial data about pieces * It can be used for transformation of pieces */ private meta; constructor(); private buildCells; isIndexValid: (index: number) => boolean; getMeta(): BoardMeta; fillBoardByMeta(meta: BoardMeta): void; getPiece: (x: number, y: number) => Piece | undefined; getPieceByCoordinate: (xy: Coordinate) => Piece | undefined; private getCell; forEachPiece(color: Color, callback: (piece: Piece, x: number, y: number) => void): void; getPieceAvailableMoves(x: number, y: number, turns: Turn[]): Action[]; /** * We keep all killed and removed from the board pieces here. * Transformations are not included. */ private killed; updateCellsOnMove(affects: Action): void; revertMove(affects: Action): void; duplicatePosition(cells: Cell[][]): Cell[][]; findUniqPiece(color: Color, pieceType: PieceType): Coordinate; }