fix various small gaps, give option for players to leave

This commit is contained in:
AlecM33
2023-08-04 00:15:29 -04:00
parent 7c61b3a724
commit 0c92455e0e
11 changed files with 182 additions and 53 deletions

View File

@@ -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
);
}
},