Skip to content

Commit

Permalink
Timer guard intialized
Browse files Browse the repository at this point in the history
  • Loading branch information
SamriddhaKharel committed Apr 22, 2024
1 parent 49e64c1 commit 567d809
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions html/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ var connection = null;
let wordgrid = null;
var serverUrl;
let gridsize = 30;
let timerActive = false;

inputCoords = [];
var chatSocket = null;
// Player attributes?
Expand Down Expand Up @@ -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');
Expand All @@ -324,6 +333,7 @@ function startTimer() {
setTimeout(updateDisplay, 1000); // Schedule the next update
} else {
timerDiv.textContent = 'Time Over!';
timerActive = false;
}
}

Expand Down

0 comments on commit 567d809

Please sign in to comment.