mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-29 09:17:51 +01:00
fix bug with restoring moderator when restarting game
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { globals } from '../../config/globals.js';
|
||||
import { Confirmation } from '../front_end_components/Confirmation.js';
|
||||
|
||||
export class GameTimerManager {
|
||||
constructor (stateBucket, socket) {
|
||||
@@ -88,11 +89,18 @@ export class GameTimerManager {
|
||||
}
|
||||
|
||||
displayExpiredTime () {
|
||||
const currentBtn = document.querySelector('#play-pause img');
|
||||
const currentBtn = document.querySelector('#timer-container-moderator #play-pause img');
|
||||
if (currentBtn) {
|
||||
currentBtn.removeEventListener('click', this.pauseListener);
|
||||
currentBtn.removeEventListener('click', this.playListener);
|
||||
currentBtn.remove();
|
||||
currentBtn.classList.add('disabled');
|
||||
currentBtn.setAttribute('src', '/images/play-pause-placeholder.svg');
|
||||
} else {
|
||||
document.querySelector('#play-pause-placeholder')?.remove();
|
||||
const placeholderBtn = document.createElement('img');
|
||||
placeholderBtn.setAttribute('src', '../images/play-pause-placeholder.svg');
|
||||
placeholderBtn.classList.add('disabled');
|
||||
document.getElementById('play-pause').appendChild(placeholderBtn);
|
||||
}
|
||||
|
||||
const timer = document.getElementById('game-timer');
|
||||
@@ -123,6 +131,12 @@ export class GameTimerManager {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (!socket.hasListeners(globals.COMMANDS.END_TIMER)) {
|
||||
socket.on(globals.COMMANDS.END_TIMER, () => {
|
||||
Confirmation('The timer has expired!');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
swapToPlayButton () {
|
||||
|
||||
Reference in New Issue
Block a user