diff --git a/src/components/boards/Board.tsx b/src/components/boards/Board.tsx index c9038414..bb47fbbd 100644 --- a/src/components/boards/Board.tsx +++ b/src/components/boards/Board.tsx @@ -398,6 +398,20 @@ function Board({ useHotkeys(keyMap.TOGGLE_EVAL_BAR.keys, () => setEvalOpen((e) => !e)); + const square = match(currentNode) + .with({ san: "O-O" }, ({ halfMoves }) => + parseSquare(halfMoves % 2 === 1 ? "g1" : "g8"), + ) + .with({ san: "O-O-O" }, ({ halfMoves }) => + parseSquare(halfMoves % 2 === 1 ? "c1" : "c8"), + ) + .otherwise((node) => node.move?.to); + + const lastMove = + currentNode.move && square + ? [chessgroundMove(currentNode.move)[0], makeSquare(square)!] + : undefined; + return ( <> @@ -425,10 +439,10 @@ function Board({ } }} > - {currentNode.annotation && currentNode.move && ( + {currentNode.annotation && currentNode.move && square && ( )} @@ -500,13 +514,7 @@ function Board({ }} turnColor={turn} check={pos?.isCheck()} - lastMove={ - editingMode - ? undefined - : currentNode.move - ? chessgroundMove(currentNode.move) - : undefined - } + lastMove={editingMode ? undefined : lastMove} premovable={{ enabled: false, }}