Update rooms.ts for numeric player IDs
- Changed Player.id from string to number - Removed name field from Player interface - Updated publicRoom to not expose name field - Players are now identified by numeric IDs only
This commit is contained in:
42
src/rooms.ts
42
src/rooms.ts
@@ -11,11 +11,10 @@ export interface RoomSettings {
|
||||
}
|
||||
|
||||
export interface Player {
|
||||
id: string;
|
||||
name: string;
|
||||
teamIndex: number | null;
|
||||
ws: ServerWebSocket<unknown> | null;
|
||||
isConnected: boolean;
|
||||
id: number;
|
||||
teamIndex: number | null;
|
||||
ws: ServerWebSocket<unknown> | null;
|
||||
isConnected: boolean;
|
||||
}
|
||||
|
||||
export interface BuzzerState {
|
||||
@@ -69,23 +68,22 @@ export function freshBuzzer(): BuzzerState {
|
||||
}
|
||||
|
||||
export function publicRoom(room: Room) {
|
||||
return {
|
||||
id: room.id,
|
||||
settings: room.settings,
|
||||
locked: room.locked,
|
||||
teamLocked: room.teamLocked,
|
||||
modOnline: room.modWs !== null,
|
||||
buzzerState: {
|
||||
roundOpen: room.buzzerState.roundOpen,
|
||||
buzzOrder: room.buzzerState.buzzOrder,
|
||||
},
|
||||
players: Array.from(room.players.values()).map(p => ({
|
||||
id: p.id,
|
||||
name: p.name,
|
||||
teamIndex: p.teamIndex,
|
||||
isConnected: p.isConnected,
|
||||
})),
|
||||
};
|
||||
return {
|
||||
id: room.id,
|
||||
settings: room.settings,
|
||||
locked: room.locked,
|
||||
teamLocked: room.teamLocked,
|
||||
modOnline: room.modWs !== null,
|
||||
buzzerState: {
|
||||
roundOpen: room.buzzerState.roundOpen,
|
||||
buzzOrder: room.buzzerState.buzzOrder,
|
||||
},
|
||||
players: Array.from(room.players.values()).map(p => ({
|
||||
id: p.id,
|
||||
teamIndex: p.teamIndex,
|
||||
isConnected: p.isConnected,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
export function broadcast(room: Room, msg: object, exclude?: ServerWebSocket<unknown>) {
|
||||
|
||||
Reference in New Issue
Block a user