@real_one_chess_king/game-logic
Version:
R.O.C.K. chess game logic
43 lines (42 loc) • 1.46 kB
TypeScript
import { Board } from "../board/board";
import { Turn } from "../turn";
import { Color } from "../color";
import { Node } from "./moves-tree.types";
import { GlobalRule } from "../rules/global/check-mate.global-rule";
/**
* This structure keep all possible moves for both players
* Root keeps all moves for currentColor, each node keeps all possible moves for the next player.
* It applies node marks from global rules.
* Restrictions: checkmate/stalemate can not be detected on the first turn.
* So all tests on check mate should contains at least one process turn cal
*/
export declare class MovesTree {
private board;
private initialTurns;
private globalRules;
private length;
private root;
constructor(board: Board, // original b
initialTurns: Turn[], globalRules: GlobalRule[], length: number, currentColor: Color);
private fillUpRoot;
/**
* Move root to the next level by turn data
* @param fromCoordinate
* @param fromCoordinate
* @param selectedPieceType - using for transforming pawn to another piece
*/
processTurn(turn: Turn): void;
getRoot(): Node;
private createEmptyNode;
private applyGlobalRules;
private raiseTree;
/**
* It cuts off all invalid moves from the tree
* Like moves that leads to check
*/
private treeShaking;
private forEachChild;
private forEachSubTreeLeaf;
private updateBoard;
private fillUpNode;
}