From 206f6d333346fa3492f879ef271fa5cd52fd0663 Mon Sep 17 00:00:00 2001 From: evanpelle Date: Wed, 16 Oct 2024 20:34:57 -0700 Subject: [PATCH] Can select map on private lobbies --- src/client/ClientGame.ts | 7 ++++++- src/client/HostLobbyModal.ts | 15 +++++++++++++-- src/core/Schemas.ts | 10 ++++++++-- src/server/GameManager.ts | 16 +++++++++++++--- src/server/GameServer.ts | 15 ++++++++++++--- src/server/Server.ts | 6 +++--- 6 files changed, 55 insertions(+), 14 deletions(-) diff --git a/src/client/ClientGame.ts b/src/client/ClientGame.ts index 52cfd3465..4720571e2 100644 --- a/src/client/ClientGame.ts +++ b/src/client/ClientGame.ts @@ -46,7 +46,7 @@ export function joinLobby(lobbyConfig: LobbyConfig, onjoin: () => void): () => v console.log('lobby: game started') onjoin() const gameConfig = { - map: GameMap.World, + map: message.config?.gameMap || lobbyConfig.map, clientID: clientID, gameID: lobbyConfig.gameID, ip: lobbyConfig.ip, @@ -93,6 +93,7 @@ export class GameRunner { private intervalID: NodeJS.Timeout private isProcessingTurn = false + private hasJoined = false constructor( private id: ClientID, @@ -125,6 +126,7 @@ export class GameRunner { }; const onmessage = (message: ServerMessage) => { if (message.type == "start") { + this.hasJoined = true console.log("starting game!") for (const turn of message.turns) { if (turn.turnNumber < this.turns.length) { @@ -134,6 +136,9 @@ export class GameRunner { } } if (message.type == "turn") { + if (!this.hasJoined) { + return + } if (this.turns.length != message.turn.turnNumber) { console.error(`got wrong turn have turns ${this.turns.length}, received turn ${message.turn.turnNumber}`) } else { diff --git a/src/client/HostLobbyModal.ts b/src/client/HostLobbyModal.ts index 893d07545..d8b13f12c 100644 --- a/src/client/HostLobbyModal.ts +++ b/src/client/HostLobbyModal.ts @@ -111,7 +111,7 @@ export class HostLobbyModal extends LitElement {