fix(games): fix chess piece interaction and solo mode
Some checks failed
Deploy to Production / test (push) Failing after 32s

Two bugs fixed:
- Piece <img> elements were intercepting pointer events, preventing
  dnd-kit drag handlers and square click handlers from firing. Added
  pointerEvents: "none" so events pass through to the board framework.
- Solo test mode (fillRoom with duplicate player IDs) always resolved
  to "white" in colorOfPlayer, making black moves impossible. Now
  detects duplicate IDs and returns the current turn's color instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
syntaxbullet
2026-04-05 17:23:16 +02:00
parent a29bb63a1d
commit 12809623c1
3 changed files with 50 additions and 4 deletions

View File

@@ -7,8 +7,14 @@ import type {
import { TIME_CONTROLS } from "./chess.types";
function colorOfPlayer(state: ChessState, playerId: string): "white" | "black" | null {
if (state.players.white === playerId) return "white";
if (state.players.black === playerId) return "black";
const isWhite = state.players.white === playerId;
const isBlack = state.players.black === playerId;
if (isWhite && isBlack) {
// Solo test mode — same player controls both sides, return current turn
return currentTurn(state.fen);
}
if (isWhite) return "white";
if (isBlack) return "black";
return null;
}