Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// enableVerbs.js

(function () {
  /*global adventurejs A*/

  var p = adventurejs.Dictionary.prototype;

  /**
   * A method to allow authors to reenable verbs.
   * @memberOf adventurejs.Dictionary
   * @method adventurejs.Dictionary#enableVerbs
   * @param {Array|String} disabled_verbs
   */
  p.enableVerbs = function (disabled_verbs) {
    // can take string or array, so convert to array
    if ("string" === typeof disabled_verbs) {
      disabled_verbs = [disabled_verbs];
    }
    for (var i = 0; i < disabled_verbs.length; i++) {
      var verb = disabled_verbs[i];
      if (!this.verbs[verb]) {
        if (A.Preverbs[verb]) {
          this.createVerb(A.Preverbs[verb]);
          this.disabled_verbs.splice(this.disabled_verbs.indexOf(verb), 1);
        }
      }
    }
  };
})();