From 322b932dbd3534761dbae265c92e78ac7c7d4bd8 Mon Sep 17 00:00:00 2001 From: MaciejkaG Date: Sat, 6 Apr 2024 21:44:18 +0200 Subject: [PATCH] Minor bug fixes --- index.js | 9 ++++++++- public/assets/js/socket-game.js | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 55c8d43..938daa1 100644 --- a/index.js +++ b/index.js @@ -555,7 +555,10 @@ io.on('connection', async (socket) => { return; } - if (playerGame && playerGame.data.state === 'preparation') { + const playerIdx = playerGame.data.hostId === session.userId ? 0 : 1; + const userNotReady = !playerGame.data.ready[playerIdx]; + + if (playerGame && playerGame.data.state === 'preparation' && userNotReady) { await GInfo.setReady(socket); const playerGame = await GInfo.getPlayerGameData(socket); @@ -563,10 +566,14 @@ io.on('connection', async (socket) => { // Both set ready await GInfo.resetTimer(playerGame.id); + callback(); + await finishPrepPhase(socket, playerGame); } else if (playerGame.data.ready[0] || playerGame.data.ready[1]) { // One player set ready + callback(); + const members = [...roomMemberIterator(playerGame.id)]; for (let i = 0; i < members.length; i++) { const sid = members[i][0]; diff --git a/public/assets/js/socket-game.js b/public/assets/js/socket-game.js index 4f2e146..dca9258 100644 --- a/public/assets/js/socket-game.js +++ b/public/assets/js/socket-game.js @@ -255,6 +255,8 @@ socket.on('turn update', (turnData) => { $(".boardSwitch").css("opacity", 0.3); } else { if (!postPrep) { + $(".readyButton").css({ pointerEvents: 'none', opacity: 0.3 }); + $(".controlsOwnBoard").css("opacity", 0.3); $(".ownBoardInfo").addClass("changing");