From b3e5cd9b2127f1659cf1d290e3b99bd9f9d0d058 Mon Sep 17 00:00:00 2001 From: vincentastolfi Date: Wed, 22 May 2024 16:30:59 +0200 Subject: [PATCH] :bug: correction of a bug that occurs when multiple Game at the same time --- app.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app.js b/app.js index 910fc75..0b199b1 100644 --- a/app.js +++ b/app.js @@ -66,9 +66,8 @@ io.on("connection", (socket) => { }); socket.on("get ennemy", (roomId, id, callack) => { - const out = players.find((p) => p.id !== id) - //const out = rooms.find((r) => r.id === roomId) - // .players.find((p) => p.id !== id); + const room = rooms.find((r) => r.id === roomId); + const out = room.players.find((p) => p.id !== id); callack({ player: out, @@ -99,7 +98,6 @@ io.on("connection", (socket) => { }); const askToPlay = (game) => { - console.log(game.actualPlayer) io.to(game.actualPlayer).emit("play"); }; @@ -191,7 +189,7 @@ class Room { }); }); } - + generateRoomId() { const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; const idLength = 5;