yet yet yet another attempt

This commit is contained in:
IM23a-cernik
2025-04-28 15:10:53 +02:00
parent 14d6c84972
commit 3a46b14322
+8 -8
View File
@@ -30,6 +30,14 @@ app.get("/lobby/create", async (req, res) => {
} }
let lobbyId = await createLobby(); 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}`); res.redirect(`/lobby/join?lobbyId=${lobbyId}&username=${username}`);
}) })
@@ -46,14 +54,6 @@ app.get("/lobby/join", async (req, res) => {
if (lobbyId in playerMap) { if (lobbyId in playerMap) {
await joinLobby(lobbyId, user.username); await joinLobby(lobbyId, user.username);
if (!playerMap[lobbyId]) {
playerMap[lobbyId] = [];
}
if (!playerMap[lobbyId].includes(username)) {
playerMap[lobbyId].push(username);
}
res.json({lobbyId, username}); res.json({lobbyId, username});
} else console.log("Lobby with " + lobbyId + " not found."); } else console.log("Lobby with " + lobbyId + " not found.");
}); });