diff --git a/game.js b/game.js index 6441a32..8837410 100644 --- a/game.js +++ b/game.js @@ -13,7 +13,7 @@ function initGamePostSetup(state) { const holder = document.querySelector("#player-info"); holder.innerHTML = ""; - + Object.entries(state.player.stats).forEach(([key, val]) => { 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) { if (config.loop) { const timeout = setTimeout(() => { - const result = config.func(state); + const result = config.func(state, config); refresh(); // the timer may have terminated itself! @@ -96,8 +96,15 @@ function startTimer(config, state) { if (state.timers.some(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); + } + } }, config.delay); diff --git a/stories/fen-snack.js b/stories/fen-snack.js index 1e0a60d..d9d4c58 100644 --- a/stories/fen-snack.js +++ b/stories/fen-snack.js @@ -40,15 +40,15 @@ stories.push({ let bonus = state.player.flags.submission ? 10 : 1; if (location.startsWith("stomach")) { - state.player.stats.health.value -= 1 * bonus; + state.player.stats.health.value -= 1; } if (location.startsWith("intestines")) { - state.player.stats.health.value -= 0.75 * bonus; + state.player.stats.health.value -= 0.75; } if (location.startsWith("bowels")) { - state.player.stats.health.value -= 0.5 * bonus; + state.player.stats.health.value -= 0.5; } @@ -69,7 +69,7 @@ stories.push({ return false; } - return true; + return 1000 / bonus; }, delay: 1000, loop: true,