瀏覽代碼

Can stop all timers without a class, too

tags/v0.1.0
Fen Dweller 6 年之前
父節點
當前提交
16a32e1e85
共有 1 個檔案被更改,包括 10 行新增3 行删除
  1. +10
    -3
      game.js

+ 10
- 3
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));

}



Loading…
取消
儲存