mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
fix various small gaps, give option for players to leave
This commit is contained in:
@@ -37,6 +37,25 @@ const Events = [
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
id: EVENT_IDS.LEAVE_ROOM,
|
||||
stateChange: async (game, socketArgs, vars) => {
|
||||
const toBeClearedIndex = game.people.findIndex(
|
||||
(person) => person.id === socketArgs.personId && person.assigned === true
|
||||
);
|
||||
if (toBeClearedIndex >= 0) {
|
||||
game.people.splice(toBeClearedIndex, 1);
|
||||
game.isStartable = vars.gameManager.isGameStartable(game);
|
||||
}
|
||||
},
|
||||
communicate: async (game, socketArgs, vars) => {
|
||||
vars.gameManager.namespace.in(game.accessCode).emit(
|
||||
EVENT_IDS.LEAVE_ROOM,
|
||||
socketArgs.personId,
|
||||
game.isStartable
|
||||
);
|
||||
}
|
||||
},
|
||||
{
|
||||
id: EVENT_IDS.UPDATE_GAME_ROLES,
|
||||
stateChange: async (game, socketArgs, vars) => {
|
||||
@@ -56,7 +75,8 @@ const Events = [
|
||||
vars.gameManager.namespace.in(game.accessCode).emit(
|
||||
EVENT_IDS.UPDATE_GAME_ROLES,
|
||||
game.deck,
|
||||
game.gameSize
|
||||
game.gameSize,
|
||||
game.isStartable
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user