|
|
@@ -8,8 +8,6 @@ function initGame(story, state) { |
|
|
state.player.stats.health = 100; |
|
|
state.player.stats.health = 100; |
|
|
|
|
|
|
|
|
state.timers = []; |
|
|
state.timers = []; |
|
|
|
|
|
|
|
|
state.timers.global = new Set(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// TODO: format string this lol |
|
|
// TODO: format string this lol |
|
|
@@ -55,9 +53,12 @@ Returns the timeout id - but you still need to cancel it through stopTimer! |
|
|
function startTimer(config, state) { |
|
|
function startTimer(config, state) { |
|
|
if (config.loop) { |
|
|
if (config.loop) { |
|
|
const timeout = setTimeout(() => { |
|
|
const timeout = setTimeout(() => { |
|
|
config.func(); |
|
|
|
|
|
|
|
|
const result = config.func(state); |
|
|
state.timers = state.timers.filter(x => x.timeout != timeout); |
|
|
state.timers = state.timers.filter(x => x.timeout != timeout); |
|
|
startTimer(config, state); |
|
|
|
|
|
|
|
|
refresh(); |
|
|
|
|
|
|
|
|
|
|
|
if (result) |
|
|
|
|
|
startTimer(config, state); |
|
|
}, config.delay); |
|
|
}, config.delay); |
|
|
|
|
|
|
|
|
state.timers.push({id: config.id, timeout: timeout, room: config.room}); |
|
|
state.timers.push({id: config.id, timeout: timeout, room: config.room}); |
|
|
|