//stopInterval.js
(function () {
/* global adventurejs A */
var p = adventurejs.Game.prototype;
/**
* Intervals are callback functions used to fire in-game events
* every turn. For example, turn on a water faucet and the faucet
* pours water every turn until it's turned off.
* stopInterval removes callback functions from the list.
* @memberof adventurejs.Game
* @method adventurejs.Game#stopInterval
* @param {Object} params The parameters for the interval.
* @param {string} params.id The id of the Asset which owns the function.
* @param {Function} params.callback The function to stop.
*/
p.stopInterval = function Game_stopInterval({ id, callback }) {
this.game.log(
"L1617",
"log",
"high",
`[Game.js] stopInterval(${id})`,
"Game"
);
if (
"undefined" === typeof id ||
"undefined" === typeof this.world._intervals[id] ||
"undefined" === typeof this.world._intervals[id][callback]
) {
return;
}
delete this.world._intervals[id][callback];
if (0 === Object.keys(this.world._intervals[id]).length) {
delete this.world._intervals[id];
}
};
})();