import type { Color, DirectionIndex, FriendlyPiece, Graph, Index, ParsedGame, PositionIndex, Positions, Unoccupied } from './base'; import type { ToPositions } from '@/notation'; /** * Walk along the board, stopping short of friendly pieces **/ export type Walk, // <- cannot walk to center index Acc extends Index[] = [], To = Graph[From][Direction]> = To extends Index ? Game['board'][To] extends Unoccupied ? Walk : Game['board'][To] extends FriendlyPiece ? Acc : [...Acc, To] : Acc; /** * Walk and cast results to positions */ export type WalkPositions, Path = Walk> = Path extends Index[] ? ToPositions : never;