From 46f74b620110fca1ab6285eb81d47bb891422184 Mon Sep 17 00:00:00 2001 From: partha120804 <138643473+partha120804@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:52:18 +0530 Subject: [PATCH 1/2] reference correction --- js/game.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/js/game.js b/js/game.js index db64f55..e394750 100644 --- a/js/game.js +++ b/js/game.js @@ -48,8 +48,7 @@ class Game { onPlayerWin() { this.isGameover = true - bgMusic.pause(); - let winSound = new Audio('./sounds/win.mp3'); + let winSound = new Audio('../assets/sounds/win.mp3'); winSound.play(); const player = this.players.reduce((prev, current) => { From 9a79c86042e5eff0ba15ca95b2595e5b1d1fd561 Mon Sep 17 00:00:00 2001 From: partha120804 <138643473+partha120804@users.noreply.github.com> Date: Wed, 3 Jul 2024 00:28:42 +0530 Subject: [PATCH 2/2] added --- js/game.js | 33 ++++++++++++++------------- pages/game.html | 16 +++++++++---- styles/game.style.css | 52 +++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 79 insertions(+), 22 deletions(-) diff --git a/js/game.js b/js/game.js index e394750..2c81ebc 100644 --- a/js/game.js +++ b/js/game.js @@ -55,20 +55,21 @@ class Game { return prev.filledBoxes > current.filledBoxes ? prev : current }); - setTimeout(() => { - let play = this.players[0].filledBoxes - - //Check for winner - if (this.players.every((p) => p.filledBoxes == play)) { - this.playerNameUI.parentElement.textContent = "Nobody wins" - this.playerTurnBgUI.classList.add("no-win") - this.playerTurnBgUI.style.background = "#eaeaea" - } else { - this.playerNameUI.parentElement.textContent = `${player.name} wins` - this.playerTurnBgUI.classList.add("win") - this.playerTurnBgUI.style.background = player.color - } - }, 500); + let play = this.players[0].filledBoxes + + //Check for winner + if (this.players.every((p) => p.filledBoxes == play)) { + this.playerNameUI.parentElement.textContent = "Nobody wins" + this.playerTurnBgUI.classList.add("no-win") + this.playerTurnBgUI.style.background = "#eaeaea" + } else { + this.playerNameUI.parentElement.textContent = `${player.name} wins` + this.playerTurnBgUI.classList.add("win") + this.playerTurnBgUI.style.background = player.color + } + + // Open the win overlay + document.getElementById("win-overlay").style.height = "100%"; } onPlayerSwitch() { @@ -182,10 +183,10 @@ document.addEventListener("DOMContentLoaded", () => { soundToggleBtn.addEventListener("click", () => { if (bgMusic.paused) { bgMusic.play(); - soundToggleBtn.innerText = "Sound Off"; + soundToggleBtn.innerText = "Sound On"; } else { bgMusic.pause(); - soundToggleBtn.innerText = "Sound On"; + soundToggleBtn.innerText = "Sound Off"; } }); }); diff --git a/pages/game.html b/pages/game.html index 0919aa1..7d702d5 100644 --- a/pages/game.html +++ b/pages/game.html @@ -25,7 +25,7 @@
- +