successful editing of role list

This commit is contained in:
AlecM33
2023-08-03 16:52:03 -04:00
parent 0d82227824
commit 24ae53209f
19 changed files with 260 additions and 103 deletions

View File

@@ -1,6 +1,7 @@
const globals = require('../config/globals');
const GameStateCurator = require('./GameStateCurator');
const UsernameGenerator = require('./UsernameGenerator');
const GameCreationRequest = require('../model/GameCreationRequest');
const EVENT_IDS = globals.EVENT_IDS;
const Events = [
@@ -57,6 +58,28 @@ const Events = [
);
}
},
{
id: EVENT_IDS.UPDATE_GAME_ROLES,
stateChange: async (game, socketArgs, vars) => {
if (GameCreationRequest.deckIsValid(socketArgs.deck)) {
game.deck = socketArgs.deck;
game.gameSize = socketArgs.deck.reduce(
(accumulator, currentValue) => accumulator + currentValue.quantity,
0
);
}
},
communicate: async (game, socketArgs, vars) => {
if (vars.ackFn) {
vars.ackFn();
}
vars.gameManager.namespace.in(game.accessCode).emit(
EVENT_IDS.UPDATE_GAME_ROLES,
game.deck,
game.gameSize
);
}
},
{
id: EVENT_IDS.ADD_SPECTATOR,
stateChange: async (game, socketArgs, vars) => {