diff --git a/client/src/modules/GameTimerManager.js b/client/src/modules/GameTimerManager.js index 2e977a6..6313512 100644 --- a/client/src/modules/GameTimerManager.js +++ b/client/src/modules/GameTimerManager.js @@ -150,16 +150,6 @@ export class GameTimerManager { pauseBtn.addEventListener('click', this.pauseListener); document.getElementById('play-pause').appendChild(pauseBtn); } - - processTimeRemaining (timeRemaining, paused, timerWorker) { - if (paused) { - this.displayPausedTime(timeRemaining); - } else if (timeRemaining === 0) { - this.displayExpiredTime(); - } else { - this.resumeGameTimer(timeRemaining, globals.CLOCK_TICK_INTERVAL_MILLIS, null, timerWorker); - } - } } function returnHumanReadableTime (milliseconds, tenthsOfSeconds = false) { diff --git a/client/src/scripts/game.js b/client/src/scripts/game.js index 7bb4a74..f6778d7 100644 --- a/client/src/scripts/game.js +++ b/client/src/scripts/game.js @@ -11,19 +11,14 @@ import { injectNavbar } from '../modules/Navbar.js'; const game = () => { injectNavbar(); - let timerWorker; + const timerWorker = new Worker(new URL('../modules/Timer.js', import.meta.url)); const socket = io('/in-game'); socket.on('disconnect', () => { - if (timerWorker) { - timerWorker.terminate(); - } - timerWorker = null; toast('Disconnected. Attempting reconnect...', 'error', true, false); }); socket.on('connect', () => { console.log("connect event fired"); socket.emit(globals.COMMANDS.GET_ENVIRONMENT, function (returnedEnvironment) { - timerWorker = new Worker(new URL('../modules/Timer.js', import.meta.url)); prepareGamePage(returnedEnvironment, socket, timerWorker); }); }); @@ -141,9 +136,7 @@ function processGameState (currentGameState, userId, socket, gameStateRenderer, break; } if (currentGameState.timerParams) { - socket.emit(globals.COMMANDS.GET_TIME_REMAINING, currentGameState.accessCode, (timeRemaining, paused) => { - gameTimerManager.processTimeRemaining(timeRemaining, paused, timerWorker); - }); + socket.emit(globals.COMMANDS.GET_TIME_REMAINING, currentGameState.accessCode); } else { document.querySelector('#game-timer')?.remove(); document.querySelector('label[for="game-timer"]')?.remove();