Clear turn timer when client disconnects
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
1924f969bc
commit
c71322af42
@ -1850,10 +1850,18 @@ const clearTimeNotice= (game, session) => {
|
||||
|
||||
const startTurnTimer = (game, session) => {
|
||||
const timeout = 90;
|
||||
if (!session.connection) {
|
||||
console.log(`${session.id}: Aborting turn timer as ${session.name} is disconnected.`);
|
||||
} else {
|
||||
console.log(`${session.id}: (Re)setting turn timer for ${session.name} to ${timeout} seconds.`);
|
||||
}
|
||||
if (game.turnTimer) {
|
||||
clearTimeout(game.turnTimer);
|
||||
}
|
||||
if (!session.connected) {
|
||||
game.turnTimer = 0;
|
||||
return;
|
||||
}
|
||||
game.turnTimer = setTimeout(() => {
|
||||
console.log(`${session.id}: Turn timer expired for ${session.name}`);
|
||||
session.player.turnNotice = 'It is still your turn.';
|
||||
|
Loading…
x
Reference in New Issue
Block a user