Can select map on private lobbies

This commit is contained in:
evanpelle
2024-10-16 20:34:57 -07:00
parent d92dc9eba6
commit 206f6d3333
6 changed files with 55 additions and 14 deletions
+6 -1
View File
@@ -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 {