cleaner styling, display start game prompt

This commit is contained in:
Alec
2021-11-16 22:42:44 -05:00
parent d9ae7db7b9
commit b6edc941fc
19 changed files with 320 additions and 52 deletions

View File

@@ -6,6 +6,7 @@ class Game {
this.deck = deck;
this.hasTimer = hasTimer;
this.timerParams = timerParams;
this.isFull = false;
}
}

View File

@@ -191,9 +191,12 @@ function handleRequestForGameState(namespace, logger, gameRunner, accessCode, pe
unassignedPerson.assigned = true;
unassignedPerson.socketId = socket.id;
ackFn(GameStateCurator.getGameStateFromPerspectiveOfPerson(game, unassignedPerson));
let isFull = isGameFull(game);
game.isFull = isFull;
socket.to(accessCode).emit(
globals.EVENTS.PLAYER_JOINED,
{ name: unassignedPerson.name }
{name: unassignedPerson.name},
isFull
);
} else {
rejectClientRequestForGameState(ackFn);
@@ -220,4 +223,8 @@ function findPersonWithMatchingSocketId(people, socketId) {
return people.find((person) => person.socketId === socketId);
}
function isGameFull(game) {
return game.moderator.assigned === true && !game.people.find((person) => person.assigned === false);
}
module.exports = Singleton;

View File

@@ -28,7 +28,8 @@ function getGameStateBasedOnPermissions(game, person) {
return person.assigned === true && person.id !== client.id && person.userType !== globals.USER_TYPES.MODERATOR
})
.map((filteredPerson) => ({ name: filteredPerson.name, userType: filteredPerson.userType })),
timerParams: game.timerParams
timerParams: game.timerParams,
isFull: game.isFull
}
case globals.USER_TYPES.MODERATOR:
return {
@@ -38,7 +39,8 @@ function getGameStateBasedOnPermissions(game, person) {
client: client,
deck: game.deck,
people: mapPeopleForModerator(game.people, client),
timerParams: game.timerParams
timerParams: game.timerParams,
isFull: game.isFull
}
case globals.USER_TYPES.TEMPORARY_MODERATOR:
return {
@@ -48,7 +50,8 @@ function getGameStateBasedOnPermissions(game, person) {
client: client,
deck: game.deck,
people: mapPeopleForTempModerator(game.people, client),
timerParams: game.timerParams
timerParams: game.timerParams,
isFull: game.isFull
}
default:
break;