This commit is contained in:
@@ -60,15 +60,17 @@ export class RoomManager {
|
||||
const room = this.rooms.get(roomId);
|
||||
if (!room) return { ok: false, error: "Room not found" };
|
||||
|
||||
// Reconnecting player: must be checked before the in-progress spectator guard.
|
||||
if (preferAs !== "spectator" && room.players.includes(playerId)) {
|
||||
room.spectators.delete(playerId);
|
||||
return { ok: true, joinedAs: "player", started: room.status === "playing" };
|
||||
}
|
||||
|
||||
if (preferAs === "spectator" || room.status !== "waiting") {
|
||||
room.spectators.add(playerId);
|
||||
return { ok: true, joinedAs: "spectator", started: room.status === "playing" };
|
||||
}
|
||||
|
||||
if (room.players.includes(playerId)) {
|
||||
return { ok: true, joinedAs: "player", started: false };
|
||||
}
|
||||
|
||||
const plugin = gameRegistry.get(room.gameSlug)!;
|
||||
const isAdmin = role === "admin";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user