Browse Source

Remove the room property from the timer logic

tags/v0.1.2
Fen Dweller 6 years ago
parent
commit
204ac4c68e
No known key found for this signature in database GPG Key ID: E80B35A6F11C3656
2 changed files with 4 additions and 13 deletions
  1. +2
    -10
      game.js
  2. +2
    -3
      stories/demo.js

+ 2
- 10
game.js View File

@@ -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));


+ 2
- 3
stories/demo.js View File

@@ -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": [
{


Loading…
Cancel
Save