MCPcopy Create free account
hub / github.com/code100x/chess / isPromoting

Function isPromoting

apps/frontend/src/components/ChessBoard.tsx:18–41  ·  view source on GitHub ↗
(chess: Chess, from: Square, to: Square)

Source from the content-addressed store, hash-verified

16import { isBoardFlippedAtom, movesAtom, userSelectedMoveIndexAtom } from '@repo/store/chessBoard';
17
18export 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
43export const ChessBoard = memo(
44 ({

Callers 2

GameFunction · 0.90
ChessBoard.tsxFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected