From 3a46b143226e6112cefe9c3fe1565430e800d91e Mon Sep 17 00:00:00 2001 From: IM23a-cernik Date: Mon, 28 Apr 2025 15:10:53 +0200 Subject: [PATCH] yet yet yet another attempt --- lobby.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lobby.js b/lobby.js index ac5279e..3f758dc 100644 --- a/lobby.js +++ b/lobby.js @@ -30,6 +30,14 @@ app.get("/lobby/create", async (req, res) => { } let lobbyId = await createLobby(); + + if (!playerMap[lobbyId]) { + playerMap[lobbyId] = []; + } + + if (!playerMap[lobbyId].includes(username)) { + playerMap[lobbyId].push(username); + } res.redirect(`/lobby/join?lobbyId=${lobbyId}&username=${username}`); }) @@ -46,14 +54,6 @@ app.get("/lobby/join", async (req, res) => { if (lobbyId in playerMap) { await joinLobby(lobbyId, user.username); - if (!playerMap[lobbyId]) { - playerMap[lobbyId] = []; - } - - if (!playerMap[lobbyId].includes(username)) { - playerMap[lobbyId].push(username); - } - res.json({lobbyId, username}); } else console.log("Lobby with " + lobbyId + " not found."); });