From 204ac4c68e60bf26f216165b34ccb733744392b7 Mon Sep 17 00:00:00 2001 From: Fen Dweller Date: Thu, 28 Nov 2019 09:49:48 -0500 Subject: [PATCH] Remove the room property from the timer logic --- game.js | 12 ++---------- stories/demo.js | 5 ++--- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/game.js b/game.js index d11aed8..1694c70 100644 --- a/game.js +++ b/game.js @@ -98,7 +98,6 @@ function updateStatDisplay(stats, statType) { func: the function to invoke delay: how long to wait between invocations loop: false = no looping, true = loop forever - room: the room associated with the timer } Returns the timeout id - but you still need to cancel it through stopTimer! @@ -126,8 +125,8 @@ function startTimer(config, state) { } }, config.delay); - - state.timers.push({id: config.id, timeout: timeout, room: config.room, classes: config.classes || []}); + + state.timers.push({id: config.id, timeout: timeout, classes: config.classes || []}); return timeout; } @@ -139,13 +138,6 @@ function stopTimer(id, state) { state.timers = state.timers.filter(timer => timer.id != id); } -function stopRoomTimers(room, state) { - const matches = state.timers.filter(timer => timer.room == room); - matches.forEach(timer => clearTimeout(timer.timeout)); - - state.timers = state.timers.filter(timer => timer.room != room); -} - function stopClassTimers(timerClass, state, inverse) { const matches = state.timers.filter(timer => timer.classes.includes(timerClass)); const others = state.timers.filter(timer => !timer.classes.includes(timerClass)); diff --git a/stories/demo.js b/stories/demo.js index d682430..c292289 100644 --- a/stories/demo.js +++ b/stories/demo.js @@ -46,15 +46,14 @@ stories.push({ delay: 1000, loop: true, classes: [ - + "Home" ], - room: "Home", }, state); }, "exit": (room, state) => { print(["You are exiting your house"]); - stopRoomTimers("Home", state); + stopClassTimers("Home", state); }, "actions": [ {