redis part 6, fix test suites

This commit is contained in:
AlecM33
2023-01-21 15:26:50 -05:00
parent 3ab5f2ff53
commit c762f88159
9 changed files with 703 additions and 685 deletions

View File

@@ -200,7 +200,12 @@ export class InProgress {
revealedPerson.gameRole = revealData.gameRole;
revealedPerson.alignment = revealData.alignment;
if (this.stateBucket.currentGameState.client.userType === globals.USER_TYPES.MODERATOR) {
toast(revealedPerson.name + ' revealed.', 'success', true, true, 'medium');
if (revealedPerson.id === this.stateBucket.currentGameState.client.id) {
toast('You revealed your role.', 'success', true, true, 'medium');
} else {
toast(revealedPerson.name + ' revealed.', 'success', true, true, 'medium');
}
this.renderPlayersWithRoleAndAlignmentInfo(this.stateBucket.currentGameState.status === globals.STATUS.ENDED);
} else {
if (revealedPerson.id === this.stateBucket.currentGameState.client.id) {
@@ -230,9 +235,13 @@ export class InProgress {
});
if (this.stateBucket.currentGameState.timerParams) {
if (!this.stateBucket.timerWorker) {
this.stateBucket.timerWorker = new Worker(new URL('../../timer/Timer.js', import.meta.url));
if (this.stateBucket.timerWorker) {
this.stateBucket.timerWorker.terminate();
this.stateBucket.timerWorker = null;
}
this.stateBucket.timerWorker = new Worker(new URL('../../timer/Timer.js', import.meta.url));
const gameTimerManager = new GameTimerManager(this.stateBucket, this.socket);
gameTimerManager.attachTimerSocketListeners(this.socket, this.stateBucket.timerWorker);
}

View File

@@ -111,17 +111,15 @@ export class GameTimerManager {
}
attachTimerSocketListeners (socket, timerWorker) {
if (!socket.hasListeners(globals.COMMANDS.PAUSE_TIMER)) {
socket.on(globals.COMMANDS.PAUSE_TIMER, (timeRemaining) => {
this.pauseGameTimer(timerWorker, timeRemaining);
});
}
globals.TIMER_EVENTS().forEach(e => socket.removeAllListeners(e));
if (!socket.hasListeners(globals.COMMANDS.RESUME_TIMER)) {
socket.on(globals.COMMANDS.RESUME_TIMER, (timeRemaining) => {
this.resumeGameTimer(timeRemaining, globals.CLOCK_TICK_INTERVAL_MILLIS, null, timerWorker);
});
}
socket.on(globals.COMMANDS.PAUSE_TIMER, (timeRemaining) => {
this.pauseGameTimer(timerWorker, timeRemaining);
});
socket.on(globals.COMMANDS.RESUME_TIMER, (timeRemaining) => {
this.resumeGameTimer(timeRemaining, globals.CLOCK_TICK_INTERVAL_MILLIS, null, timerWorker);
});
socket.once(globals.COMMANDS.GET_TIME_REMAINING, (timeRemaining, paused) => {
if (paused) {
@@ -133,11 +131,9 @@ export class GameTimerManager {
}
});
if (!socket.hasListeners(globals.COMMANDS.END_TIMER)) {
socket.on(globals.COMMANDS.END_TIMER, () => {
Confirmation('The timer has expired!');
});
}
socket.on(globals.COMMANDS.END_TIMER, () => {
Confirmation('The timer has expired!');
});
}
swapToPlayButton () {