0
0
Fork 0

Fix bug that would remove the player from the general role room if they were switching from one team to the other, but remaining in the same role.

This commit is contained in:
Oliver-Akins 2021-01-03 00:05:22 -07:00
parent 23946e8bc1
commit fab77b06b4

View file

@ -220,13 +220,23 @@ const modifyPlayer = (io: Server, socket: Socket, data: UpdatePlayer): void => {
game.log.debug(`${player.name} left the guessers`);
oldTeam.guessers = oldTeam.guessers.filter(x => x.socket !== socket);
player.socket.leave(`${game.id}:${data.from.team}:guesser`);
player.socket.leave(`${game.id}:*:guesser`);
// Ensure we don't remove the general role room if the player
// is taking the same role, but on the other team.
if (data.from.role !== data.to.role) {
player.socket.leave(`${game.id}:*:guesser`);
};
break;
case "writer":
game.log.debug(`${player.name} stopped being a writer`);
oldTeam.writer = null;
player.socket.leave(`${game.id}:${data.from.team}:writer`);
player.socket.leave(`${game.id}:*:writer`);
// Ensure we don't remove the general role room when the player
// is taking the same role, but on the other team.
if (data.from.role !== data.to.role) {
player.socket.leave(`${game.id}:*:writer`);
};
break;
};
};