From 16a32e1e85f0fd4caffed90ac89f8364d3bbff38 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Sat, 12 Jan 2019 10:39:59 -0500 Subject: [PATCH] Can stop all timers without a class, too --- game.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/game.js b/game.js index 3be1ea3..d49925b 100644 --- a/game.js +++ b/game.js @@ -82,11 +82,18 @@ function stopRoomTimers(room, state) { } -function stopClassTimers(timerClass, state) { +function stopClassTimers(timerClass, state, inverse) { const matches = state.timers.filter(timer => timer.classes.includes(timerClass)); - matches.forEach(timer => clearTimeout(timer.timeout)); + const others = state.timers.filter(timer => !timer.classes.includes(timerClass)); + + if (inverse) { + others.forEach(timer => clearTimeout(timer.timeout)); + state.timers = matches; + } else { + matches.forEach(timer => clearTimeout(timer.timeout)); + state.timers = others; + } - state.timers = state.timers.filter(timer => !timer.classes.includes(timerClass)); }