import { BackgammonBoard } from '.'; import { BackgammonChecker } from './checker'; import { BackgammonCheckerContainer, BackgammonMoveDestination, BackgammonMoveOrigin, BackgammonPoint } from './checkercontainer'; import { BackgammonDieValue } from './dice'; import { BackgammonMoveDirection } from './game'; import { BackgammonPlayer, BackgammonPlayerMoving } from './player'; export type BackgammonMoveStateKind = 'ready' | 'completed' | 'confirmed'; export type BackgammonMoveKind = 'no-move' | 'point-to-point' | 'reenter' | 'bear-off'; export type BackgammonMoveSkeleton = { dieValue: BackgammonDieValue; direction: BackgammonMoveDirection; origin: BackgammonMoveOrigin; destination: BackgammonMoveDestination; }; export interface BackgammonMoveBase { id: string; player: BackgammonPlayer; dieValue: BackgammonDieValue; stateKind: BackgammonMoveStateKind; moveKind: BackgammonMoveKind; possibleMoves: BackgammonMoveSkeleton[]; moveHistory?: { previousBoardState: string; hitCheckers?: BackgammonChecker[]; executionTimestamp: string; undoMetadata?: { canUndo: boolean; undoChainIndex: number; originalMoveId: string; }; }; } export interface BackgammonMoveReady extends BackgammonMoveBase { stateKind: 'ready'; } export interface BackgammonMoveCompletedWithMove extends BackgammonMoveBase { stateKind: 'completed'; moveKind: 'point-to-point' | 'reenter' | 'bear-off'; origin: BackgammonMoveOrigin; destination: BackgammonMoveDestination; isHit: boolean; } export interface BackgammonMoveCompletedNoMove extends BackgammonMoveBase { stateKind: 'completed'; moveKind: 'no-move'; origin?: undefined; destination?: undefined; isHit: false; } export type BackgammonMoveCompleted = BackgammonMoveCompletedWithMove | BackgammonMoveCompletedNoMove; export interface BackgammonMoveConfirmedWithMove extends BackgammonMoveBase { stateKind: 'confirmed'; moveKind: 'point-to-point' | 'reenter' | 'bear-off'; origin: BackgammonMoveOrigin; destination: BackgammonMoveDestination; isHit: boolean; } export interface BackgammonMoveConfirmedNoMove extends BackgammonMoveBase { stateKind: 'confirmed'; moveKind: 'no-move'; origin?: undefined; destination?: undefined; isHit: false; } export type BackgammonMoveConfirmed = BackgammonMoveConfirmedWithMove | BackgammonMoveConfirmedNoMove; export type BackgammonMove = BackgammonMoveReady | BackgammonMoveCompleted | BackgammonMoveConfirmed; export interface BackgammonMoveResult { board: BackgammonBoard; move: BackgammonMoveCompleted; } export interface BackgammonMoveDryRunResult { board: BackgammonBoard; move: BackgammonMoveReady | BackgammonMoveCompleted; } export type BackgammonMoves = BackgammonMove[]; export interface MoveProps { move: BackgammonMove; origin: BackgammonMoveOrigin; } /** * MoveClass defines the interface for a class that implements Backgammon move logic. * * This interface bridges the gap between static type definitions (such as BackgammonMove, BackgammonMoveReady, etc.) * and the actual logic required to create, validate, and apply moves to a Backgammon board. * * By specifying the required methods and properties, MoveClass ensures that any implementing class * can construct moves from type-safe props, check move validity, apply moves to a board, and confirm moves. * * This approach allows the type system to enforce correct usage of move-related operations, * while enabling the implementation of move logic in a consistent and type-safe manner. */ export interface MoveClass { player: BackgammonPlayer; id: string; dieValue: BackgammonDieValue; stateKind: BackgammonMoveStateKind; moveKind: BackgammonMoveKind | undefined; origin: BackgammonCheckerContainer | undefined; destination: BackgammonCheckerContainer | undefined; initialize: (props: MoveProps) => BackgammonMove; isPointOpen: (point: BackgammonPoint, player: BackgammonPlayerMoving) => boolean; move: (board: BackgammonBoard, move: BackgammonMoveReady, isDryRun?: boolean) => BackgammonMoveResult | BackgammonMoveDryRunResult; } //# sourceMappingURL=move.d.ts.map