import type { Color, FriendlyPiece, Graph, Index, ParsedGame, ParsedMove, Unoccupied } from '../base'; import type { ToMoves } from '../utils'; export type PawnMoves = _ExpandPromotions, ..._PawnCapture, ..._PawnCapture, ..._PawnEnPassant, ..._PawnEnPassant ], From>, Friendly>; /** advance pawn forward, and if allowed advance again */ type _PawnAdvance = Graph[From][Forward] extends infer First extends Index ? Game['board'][First] extends Unoccupied ? [ First, ...From extends _PawnStartingPositions ? Graph[First][Forward] extends infer Second extends Index ? Game['board'][Second] extends Unoccupied ? [Second] : [] : [] : [] ] : [] : []; type _PawnStartingPositions = 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55; /** capture enemy piece */ type _PawnCapture = Graph[From][Direction] extends infer To extends Index ? Game['board'][To] extends FriendlyPiece | Unoccupied ? [] : [To] : []; /** capture en passant */ type _PawnEnPassant = Graph[From][Direction] extends infer To extends Game['ep'] ? Game['turn'] extends Friendly ? To extends Index ? [To] : [] : [] : []; /** promotions */ export type _ExpandPromotions = T extends [infer Head extends ParsedMove, ...infer Tail extends ParsedMove[]] ? Head['to'] extends _PawnPromotionPositions ? _ExpandPromotions : _ExpandPromotions : Acc; type _PawnPromotionPositions = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63; export {};