fix(rithmomachia): validate move path before showing capture error on hover

Fixed capture error tooltip not showing by adding path validation before
checking for invalid capture relations.

The hover error now correctly:
1. Validates the move path is legal (using validateMove)
2. Only shows if path is valid AND there's no valid capture relation
3. Prevents showing errors for moves that aren't even possible

Added import for validateMove from pathValidator utils.

This ensures the "no valid relation" tooltip only appears when you're
hovering over an enemy piece that your selected piece can legally move to,
but cannot capture due to missing valid numeric relations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock 2025-11-02 13:38:24 -06:00
parent 52554b22ac
commit bd49964186
1 changed files with 5 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import { usePieceSelection } from '../../hooks/usePieceSelection'
import { useRithmomachia } from '../../Provider'
import type { Piece, RelationKind } from '../../types'
import { getSquarePosition } from '../../utils/boardCoordinates'
import { validateMove } from '../../utils/pathValidator'
import { getEffectiveValue } from '../../utils/pieceSetup'
import {
checkDiff,
@ -454,6 +455,10 @@ export function BoardDisplay() {
if (!moverPiece || !targetPiece) return false
// First check if the move path is valid
const validation = validateMove(moverPiece, selectedSquare, hoveredSquare, state.pieces)
if (!validation.valid) return false
const moverValue = getEffectiveValue(moverPiece)
const targetValue = getEffectiveValue(targetPiece)