fix(games): fix chess piece interaction and solo mode
Some checks failed
Deploy to Production / test (push) Failing after 32s
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:
@@ -17,7 +17,13 @@ const chessPieces: PieceRenderObject = Object.fromEntries(
|
||||
<img
|
||||
src={`/pieces/${key}.svg`}
|
||||
alt={key}
|
||||
style={{ width: "100%", height: "100%", ...props?.svgStyle }}
|
||||
style={{
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
pointerEvents: "none", // let events pass through to dnd-kit / Square handlers
|
||||
userSelect: "none",
|
||||
...props?.svgStyle,
|
||||
}}
|
||||
draggable={false}
|
||||
/>
|
||||
),
|
||||
@@ -149,7 +155,9 @@ export function ChessGame({ state, myPlayerId, isSpectator, onAction, players }:
|
||||
const view = state as PlayerView | SpectatorView;
|
||||
const playerView = isPlayerView(state) ? state as PlayerView : null;
|
||||
const myColor = playerView?.myColor ?? "white";
|
||||
const boardOrientation = isSpectator ? "white" : myColor;
|
||||
// Solo mode: both players are the same user — myColor flips each turn, so lock orientation to white
|
||||
const isSoloMode = !isSpectator && players.length === 2 && players[0]?.discordId === players[1]?.discordId;
|
||||
const boardOrientation = isSpectator || isSoloMode ? "white" : myColor;
|
||||
const isMyTurn = playerView ? view.turn === playerView.myColor : false;
|
||||
const isGameOver = view.result !== null;
|
||||
const moveHistoryRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
Reference in New Issue
Block a user