fix(chess): prevent duplicate players and fix move detection
Some checks failed
Deploy to Production / test (push) Failing after 38s

- Prevent same player from joining as both white and black
- Add validation to reject duplicate players in RoomManager
- Fix spectator status not resetting when joining as player
- Use ref to track latest chess state in ChessBoard for accurate move validation
This commit is contained in:
syntaxbullet
2026-04-02 15:36:05 +02:00
parent e521d3086f
commit 26a0e532f6
4 changed files with 19 additions and 4 deletions

View File

@@ -56,13 +56,16 @@ export function useGameRoom(roomId: string, userId: string, role?: string) {
return {
...prev,
spectators: [...prev.spectators.filter(s => s.discordId !== msg.player.discordId), msg.player],
isSpectator: isMe ? true : prev.isSpectator,
isSpectator: isMe || prev.isSpectator,
roomStatus: prev.roomStatus === "connecting" ? "waiting" : prev.roomStatus,
};
}
const isMe = msg.player.discordId === userId;
return {
...prev,
players: [...prev.players.filter(p => p.discordId !== msg.player.discordId), msg.player],
isSpectator: isMe ? false : prev.isSpectator,
roomStatus: prev.roomStatus === "connecting" ? "waiting" : prev.roomStatus,
};
});