mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 07:47:50 +01:00
display current moderator, fix assignment of spectator
This commit is contained in:
@@ -96,7 +96,7 @@ const Events = [
|
||||
communicate: async (game, socketArgs, vars) => {
|
||||
const person = game.people.find((person) => person.id === socketArgs.personId);
|
||||
if (person) {
|
||||
vars.gameManager.namespace.in(game.accessCode).emit(globals.EVENT_IDS.KILL_PLAYER, person.id);
|
||||
vars.gameManager.namespace.in(game.accessCode).emit(globals.EVENT_IDS.KILL_PLAYER, person);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -189,9 +189,9 @@ const Events = [
|
||||
const moderatorSocket = vars.gameManager.namespace.sockets.get(moderator?.socketId);
|
||||
if (moderator && moderatorSocket) {
|
||||
vars.gameManager.namespace.to(moderator.socketId).emit(globals.EVENTS.SYNC_GAME_STATE);
|
||||
moderatorSocket.to(game.accessCode).emit(globals.EVENT_IDS.KILL_PLAYER, game.currentModeratorId);
|
||||
moderatorSocket.to(game.accessCode).emit(globals.EVENT_IDS.KILL_PLAYER, moderator);
|
||||
} else {
|
||||
vars.gameManager.namespace.in(game.accessCode).emit(globals.EVENT_IDS.KILL_PLAYER, game.currentModeratorId);
|
||||
vars.gameManager.namespace.in(game.accessCode).emit(globals.EVENT_IDS.KILL_PLAYER, moderator);
|
||||
}
|
||||
const previousModerator = vars.gameManager.findPersonByField(game, 'id', game.previousModeratorId);
|
||||
if (previousModerator && previousModerator.id !== moderator.id && vars.gameManager.namespace.sockets.get(previousModerator.socketId)) {
|
||||
|
||||
@@ -140,7 +140,7 @@ const ServerBootstrapper = {
|
||||
app.use('', router);
|
||||
|
||||
app.use('/dist', (req, res, next) => {
|
||||
if (req.url !== '/521-bundle.js') { // this is the bundled web worker, which was introducing compatibility problems with webpack compression.
|
||||
if (req.url.includes('.js.gz')) {
|
||||
res.set('Content-Encoding', 'gzip');
|
||||
}
|
||||
next();
|
||||
|
||||
@@ -393,6 +393,7 @@ async function addSpectator (game, name, logger, namespace, eventManager, instan
|
||||
name,
|
||||
globals.USER_TYPES.SPECTATOR
|
||||
);
|
||||
spectator.assigned = true;
|
||||
logger.trace('new spectator: ' + spectator.name);
|
||||
game.people.push(spectator);
|
||||
await refreshGame(game);
|
||||
|
||||
Reference in New Issue
Block a user