refactor GameStateRenderer, split functionality by game state

This commit is contained in:
AlecM33
2022-12-13 14:12:15 -05:00
parent a37dd966f9
commit 25897f985f
9 changed files with 596 additions and 551 deletions

View File

@@ -66,6 +66,7 @@ function getGameStateBasedOnPermissions (game, person, gameRunner) {
moderator: GameStateCurator.mapPerson(game.moderator),
client: client,
deck: game.deck,
gameSize: game.gameSize,
people: game.people
.filter((person) => {
return person.assigned === true;
@@ -88,6 +89,7 @@ function getGameStateBasedOnPermissions (game, person, gameRunner) {
moderator: GameStateCurator.mapPerson(game.moderator),
client: client,
deck: game.deck,
gameSize: game.gameSize,
people: GameStateCurator.mapPeopleForModerator(game.people, client),
timerParams: game.timerParams,
isFull: game.isFull,
@@ -100,6 +102,7 @@ function getGameStateBasedOnPermissions (game, person, gameRunner) {
moderator: GameStateCurator.mapPerson(game.moderator),
client: client,
deck: game.deck,
gameSize: game.gameSize,
people: game.people
.filter((person) => {
return person.assigned === true;
@@ -115,6 +118,7 @@ function getGameStateBasedOnPermissions (game, person, gameRunner) {
moderator: GameStateCurator.mapPerson(game.moderator),
client: client,
deck: game.deck,
gameSize: game.gameSize,
people: game.people
.filter((person) => {
return person.assigned === true;

View File

@@ -45,7 +45,7 @@ class SocketManager {
};
registerHandlers = (namespace, socket, gameManager) => {
socket.on(globals.SOCKET_EVENTS.IN_GAME_MESSAGE, async (eventId, accessCode, args, ackFn) => {
socket.on(globals.SOCKET_EVENTS.IN_GAME_MESSAGE, async (eventId, accessCode, args=null, ackFn=null) => {
const game = gameManager.activeGameRunner.activeGames.get(accessCode);
if (game) {
switch (eventId) {
@@ -63,6 +63,7 @@ class SocketManager {
break;
case EVENT_IDS.START_GAME:
gameManager.startGame(game, namespace);
ackFn();
break;
case EVENT_IDS.PAUSE_TIMER:
gameManager.pauseTimer(game, this.logger);
@@ -91,6 +92,7 @@ class SocketManager {
break;
case EVENT_IDS.END_GAME:
gameManager.endGame(game);
ackFn();
break;
default:
break;