0
0
Fork 0

Get the correct hand from the team for spirits reconnecting

This commit is contained in:
Oliver-Akins 2021-02-28 19:38:15 -07:00
parent 526e063eed
commit 04a0780225

View file

@ -122,19 +122,24 @@ export default (io: Server, socket: Socket, data: JoinGame) => {
let rooms: string[] = [game.id]; let rooms: string[] = [game.id];
game.log.info(`Player Reconnected to the game (name=${data.name})`); game.log.info(`Player Reconnected to the game (name=${data.name})`);
// Get the hand of the player's team if they are a guesser
let hand: string[] = []; let hand: string[] = [];
if (sameName.team && sameName.role == `guesser`) {
hand = game.teams[sameName.team - 1].hand;
};
// Ensure that the user has a role before connecting them to // Ensure that the user has a role before connecting them to
// the websocket rooms // the websocket rooms
if (sameName.role) { if (sameName.role && sameName.team) {
rooms.push( rooms.push(
`${game.id}:*:${sameName.role}`, `${game.id}:*:${sameName.role}`,
`${game.id}:${sameName.team}:${sameName.role}` `${game.id}:${sameName.team}:${sameName.role}`
); );
switch (sameName.role) {
case "guesser":
hand = game.teams[sameName.team - 1].hand;
break;
case "writer":
hand = game.teams[sameName.team - 1].spiritHand;
break;
};
}; };
socket.join(rooms); socket.join(rooms);