|
@ -111,13 +111,16 @@ export class Games { |
|
|
socket: WebSocket, |
|
|
socket: WebSocket, |
|
|
uuid: string, |
|
|
uuid: string, |
|
|
name: string |
|
|
name: string |
|
|
): void { |
|
|
): boolean { |
|
|
|
|
|
let succeeded: boolean = false |
|
|
const gameIndex: number | undefined = |
|
|
const gameIndex: number | undefined = |
|
|
this.playerNameToGameIndex.get(nameToSpectate) |
|
|
this.playerNameToGameIndex.get(nameToSpectate) |
|
|
if (gameIndex !== undefined) { |
|
|
if (gameIndex !== undefined) { |
|
|
this.playerNameToGameIndex.set(name, gameIndex) |
|
|
this.playerNameToGameIndex.set(name, gameIndex) |
|
|
this.games[gameIndex].addSpectator(socket, uuid, name) |
|
|
this.games[gameIndex].addSpectator(socket, uuid, name) |
|
|
|
|
|
succeeded = true |
|
|
} |
|
|
} |
|
|
|
|
|
return succeeded |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async leaveGame (name: string): Promise<void> { |
|
|
async leaveGame (name: string): Promise<void> { |
|
|