|
|
@@ -13,7 +13,7 @@ function initGamePostSetup(state) { |
|
|
const holder = document.querySelector("#player-info"); |
|
|
const holder = document.querySelector("#player-info"); |
|
|
|
|
|
|
|
|
holder.innerHTML = ""; |
|
|
holder.innerHTML = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Object.entries(state.player.stats).forEach(([key, val]) => { |
|
|
Object.entries(state.player.stats).forEach(([key, val]) => { |
|
|
|
|
|
|
|
|
if (val.type == "meter") { |
|
|
if (val.type == "meter") { |
|
|
@@ -88,7 +88,7 @@ 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(() => { |
|
|
const result = config.func(state); |
|
|
|
|
|
|
|
|
const result = config.func(state, config); |
|
|
refresh(); |
|
|
refresh(); |
|
|
|
|
|
|
|
|
// the timer may have terminated itself! |
|
|
// the timer may have terminated itself! |
|
|
@@ -96,8 +96,15 @@ function startTimer(config, state) { |
|
|
|
|
|
|
|
|
if (state.timers.some(x => x.timeout == timeout)){ |
|
|
if (state.timers.some(x => x.timeout == timeout)){ |
|
|
state.timers = state.timers.filter(x => x.timeout != timeout); |
|
|
state.timers = state.timers.filter(x => x.timeout != timeout); |
|
|
if (result) |
|
|
|
|
|
|
|
|
if (typeof(result) === "number") { |
|
|
|
|
|
config.delay = result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// you shouldn't use a delay of 0 anyway |
|
|
|
|
|
if (result) { |
|
|
startTimer(config, state); |
|
|
startTimer(config, state); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}, config.delay); |
|
|
}, config.delay); |
|
|
|