Get the correct hand from the team for spirits reconnecting
This commit is contained in:
parent
526e063eed
commit
04a0780225
1 changed files with 10 additions and 5 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue