From 8b585d16db33394cc9e0eaa388dc218f4789abff Mon Sep 17 00:00:00 2001 From: vincentastolfi Date: Thu, 8 Aug 2024 17:49:29 +0200 Subject: [PATCH 1/2] :memo: update Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 480bcdb..5c90338 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ The current state of maettleship is the following one - [X] End game (partially handled) - [X] Create an account and add it on the database - [X] Connection to your account +- [X] Rematch # TODO @@ -73,7 +74,6 @@ Those point are the feature I still need to introduce - [ ] Security improvement (hashed password, sql injection handling) - [ ] Fix all the problems linked to my rooms implementation -- [ ] Rematch - [ ] Player historic (link to its account) - [ ] Global scoreboard - [ ] General error handling From 4ad7ee59936dd0155cf129bd3583db9083d1eaa7 Mon Sep 17 00:00:00 2001 From: vincentastolfi Date: Thu, 8 Aug 2024 23:55:27 +0200 Subject: [PATCH 2/2] :bug: fix bug that occurs when someone try the join a full room --- index.js | 10 +++++++++- public/scripts/app.js | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 86b60ad..11309c0 100644 --- a/index.js +++ b/index.js @@ -202,11 +202,19 @@ io.on("connection", (socket) => { if (room == null) { callack({ - status: false + status: false, + message: "No room for this code" }) return } + if (room.players.length >= 2) { + callack({ + status: false, + message: "Room is full" + }) + } + callack({ status: true }) diff --git a/public/scripts/app.js b/public/scripts/app.js index 485e2c4..eb432cb 100644 --- a/public/scripts/app.js +++ b/public/scripts/app.js @@ -177,9 +177,7 @@ function onJoinRoom() { socket.emit("ask for room", roomKey, socket.id, (response) => { if (response.status !== true) { - if (errorHolder.textContent == "") { - errorHolder.append("Error : Room Id don't exist") - } + errorHolder.textContent = "Error : " + response.message } else { loader.style.display = "none"; roomkeyHolder.innerHTML += `Your room key is : ` + roomId + ``;