Add spectator mode for late-joining players
- Server: Late joiners are added as spectators instead of players - Server: Send forced-spectator event only to joining spectator (not broadcast) - Server: Track spectators separately and move them to players after game ends - Client: Handle forced-spectator event to show all player boards - Client: Spectators see all boards equally without main/spectator highlighting - Client: Mobile view shows scrollable vertical list of all boards for spectators - Fix: All cleared lines are sent as garbage to each opponent (not randomized) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -323,12 +323,17 @@ class TetrisRenderer {
|
||||
}
|
||||
|
||||
setActivePlayer(playerId) {
|
||||
// Remove main class from all boards
|
||||
// Remove main/spectator classes from all boards
|
||||
this.boards.forEach((boardData, id) => {
|
||||
boardData.element.classList.remove('active', 'main');
|
||||
boardData.element.classList.remove('spectator', 'top-left', 'top-right', 'bottom-left', 'bottom-right');
|
||||
});
|
||||
|
||||
// If playerId is null (spectator mode), show all boards equally without highlighting
|
||||
if (playerId === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add main class to current player
|
||||
const mainBoard = this.boards.get(playerId);
|
||||
if (mainBoard) {
|
||||
|
||||
Reference in New Issue
Block a user