(chess: Chess, from: Square, to: Square)
| 16 | import { isBoardFlippedAtom, movesAtom, userSelectedMoveIndexAtom } from '@repo/store/chessBoard'; |
| 17 | |
| 18 | export function isPromoting(chess: Chess, from: Square, to: Square) { |
| 19 | if (!from) { |
| 20 | return false; |
| 21 | } |
| 22 | |
| 23 | const piece = chess.get(from); |
| 24 | |
| 25 | if (piece?.type !== 'p') { |
| 26 | return false; |
| 27 | } |
| 28 | |
| 29 | if (piece.color !== chess.turn()) { |
| 30 | return false; |
| 31 | } |
| 32 | |
| 33 | if (!['1', '8'].some((it) => to.endsWith(it))) { |
| 34 | return false; |
| 35 | } |
| 36 | |
| 37 | return chess |
| 38 | .history({ verbose: true }) |
| 39 | .map((it) => it.to) |
| 40 | .includes(to); |
| 41 | } |
| 42 | |
| 43 | export const ChessBoard = memo( |
| 44 | ({ |
no outgoing calls
no test coverage detected