import { memo } from 'react'; import type { GhostPiece, Orientation, PieceSet, PieceRenderer, Square } from '../types'; import { PieceGlyph } from './PieceGlyph'; interface GhostPiecesLayerProps { ghosts: GhostPiece[]; orientation: Orientation; pieceSet?: PieceSet; customPieces?: PieceRenderer; flipPieces?: boolean; } function squareColRow(sq: Square, asWhite: boolean): [number, number] { const f = sq.charCodeAt(0) - 97; const r = sq.charCodeAt(1) - 49; return [asWhite ? f : 7 - f, asWhite ? 7 - r : r]; } function isValidSquare(sq: string): sq is Square { return /^[a-h][1-8]$/.test(sq); } /** * Translucent "hint" pieces for teaching: show where a piece could or should * be placed without touching the real position (e.g. "your knight belongs on * f5"). Rendered under the real pieces, non-interactive. */ export const GhostPiecesLayer = memo(function GhostPiecesLayer({ ghosts, orientation, pieceSet, customPieces, flipPieces = false, }: GhostPiecesLayerProps) { const asWhite = orientation === 'white'; return (