From 567d8096edf7f60290035049aff9279c83cec092 Mon Sep 17 00:00:00 2001 From: SamriddhaK Date: Mon, 22 Apr 2024 12:02:01 -0500 Subject: [PATCH] Timer guard intialized --- html/main.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/html/main.js b/html/main.js index a5dc3b2..eabacda 100644 --- a/html/main.js +++ b/html/main.js @@ -2,6 +2,8 @@ var connection = null; let wordgrid = null; var serverUrl; let gridsize = 30; +let timerActive = false; + inputCoords = []; var chatSocket = null; // Player attributes? @@ -309,6 +311,13 @@ function startGame(){ } function startTimer() { + + if (timerActive) { + console.log("restart the timer blocked."); + return; + } + timerActive = true; + console.log("Timer started."); let duration = 50 * 60; // 50 minutes converted to seconds const timerDiv = document.getElementById('timer'); @@ -324,6 +333,7 @@ function startTimer() { setTimeout(updateDisplay, 1000); // Schedule the next update } else { timerDiv.textContent = 'Time Over!'; + timerActive = false; } }