mirror of
https://github.com/AlecM33/Werewolf.git
synced 2025-12-26 15:57:50 +01:00
successful editing of role list
This commit is contained in:
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user