Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// isState.js
(function () {
  /*global adventurejs A*/
  "use strict";
  var p = adventurejs.Asset.prototype;
  /**
   * <strong>isState</strong> is a method to check whether
   * this asset already has state set by the specified verb.
   * @memberOf adventurejs.Asset
   * @method adventurejs.Asset#isState
   * @param {String} verb
   * @returns {Boolean}
   */
  p.isState = function Asset_isVerbState(verb) {
    if (!verb || !this.game.dictionary.verbs[verb]) return false;

    verb = this.game.dictionary.verbs[verb];

    // ex: do verb close to this and this.is.closed
    if (verb.state && this.is[verb.state]) return true;

    // ex: do verb open to this and !this.is.closed
    if (verb.unstate && !this.is[verb.unstate]) return true;

    return false;
  };
})();