mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
fix problem with updating spectator count
This commit is contained in:
@@ -50,7 +50,7 @@ export const globals = {
|
||||
SYNC_GAME_STATE: 'syncGameState',
|
||||
START_TIMER: 'startTimer',
|
||||
PLAYER_LEFT: 'playerLeft',
|
||||
NEW_SPECTATOR: 'newSpectator',
|
||||
UPDATE_SPECTATORS: 'newSpectator',
|
||||
RESTART_GAME: 'restartGame'
|
||||
},
|
||||
USER_TYPES: {
|
||||
|
||||
@@ -203,12 +203,16 @@ export class InProgress {
|
||||
}
|
||||
});
|
||||
|
||||
if (this.socket.hasListeners(globals.EVENT_IDS.NEW_SPECTATOR)) {
|
||||
this.socket.removeAllListeners(globals.EVENT_IDS.NEW_SPECTATOR);
|
||||
if (this.socket.hasListeners(globals.EVENT_IDS.UPDATE_SPECTATORS)) {
|
||||
this.socket.removeAllListeners(globals.EVENT_IDS.UPDATE_SPECTATORS);
|
||||
}
|
||||
|
||||
this.socket.on(globals.EVENT_IDS.NEW_SPECTATOR, (spectator) => {
|
||||
stateBucket.currentGameState.spectators.push(spectator);
|
||||
this.socket.on(globals.EVENT_IDS.UPDATE_SPECTATORS, (updatedSpectatorList) => {
|
||||
stateBucket.currentGameState.spectators = updatedSpectatorList;
|
||||
SharedStateUtil.setNumberOfSpectators(
|
||||
stateBucket.currentGameState.spectators.length,
|
||||
document.getElementById('spectator-count')
|
||||
);
|
||||
if (this.stateBucket.currentGameState.client.userType === globals.USER_TYPES.MODERATOR
|
||||
|| this.stateBucket.currentGameState.client.userType === globals.USER_TYPES.TEMPORARY_MODERATOR) {
|
||||
this.displayAvailableModerators();
|
||||
|
||||
@@ -99,8 +99,8 @@ export class Lobby {
|
||||
}
|
||||
});
|
||||
|
||||
this.socket.on(globals.EVENT_IDS.NEW_SPECTATOR, (spectator) => {
|
||||
this.stateBucket.currentGameState.spectators.push(spectator);
|
||||
this.socket.on(globals.EVENT_IDS.UPDATE_SPECTATORS, (updatedSpectatorList) => {
|
||||
this.stateBucket.currentGameState.spectators = updatedSpectatorList;
|
||||
SharedStateUtil.setNumberOfSpectators(
|
||||
this.stateBucket.currentGameState.spectators.length,
|
||||
document.getElementById('spectator-count')
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#join-game-modal {
|
||||
border-left: 5px solid #b1afcd;
|
||||
animation: entrance 0.5s forwards;
|
||||
transform-origin: center;
|
||||
display: block;
|
||||
z-index: 1 !important;
|
||||
@@ -46,15 +45,3 @@
|
||||
#game-code {
|
||||
font-family: "Courier New", monospace;
|
||||
}
|
||||
|
||||
@keyframes entrance {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
90% {
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user