From 04f0c6a996c9affb34d7884d52013ffb93e6133c Mon Sep 17 00:00:00 2001 From: Ann Rose Date: Mon, 9 Mar 2026 19:44:27 +0530 Subject: [PATCH] Missing Tie-Breaker Logic solved --- Memory-block-game-main/code/script.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Memory-block-game-main/code/script.js b/Memory-block-game-main/code/script.js index fbf1b03..d3a38cb 100644 --- a/Memory-block-game-main/code/script.js +++ b/Memory-block-game-main/code/script.js @@ -368,7 +368,7 @@ playSound(flipSound); if (matchedPairs === totalPairs) { playSound(winSound); - document.getElementById("congratulation-popup").style.display = "block"; + showCongratulations(); gameOver = true; } @@ -428,22 +428,18 @@ playSound(flipSound); } } - // Single winner + const popup = document.getElementById("congratulation-popup"); if (winners.length === 1) { - const popup = document.getElementById("congratulation-popup"); if (totalPlayers === 1) { popup.querySelector("p").textContent = "You completed the game! 🏆"; } else { popup.querySelector("p").textContent = `Player ${winners[0]} Wins! 🏆`; } - popup.style.display = "block"; - return; + } else { + // Handle the tie gracefully + popup.querySelector("p").textContent = `It's a Tie between Players ${winners.join(" & ")}! 🤝`; } - - // Tie detected - tieMode = true; - tiePlayers = winners; - startTieBreaker(); + popup.style.display = "block"; } function resetGame() {