Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// disableVerbs.js

(function () {
  /*global adventurejs A*/
  "use strict";

  var p = adventurejs.Dictionary.prototype;

  /**
   * A method to allow authors to disable specific verbs.
   * @memberOf adventurejs.Dictionary
   * @method adventurejs.Dictionary#disableVerbs
   * @param {String|Array} disabled_verbs
   */
  p.disableVerbs = function (disabled_verbs) {
    console.warn("disableVerbs", 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 ("undefined" === typeof this.verb_lookup[verb]) {
        var msg = "disableVerbs received unknown verb " + verb + ". ";
        this.game.log("warn", "critical", msg, "dictionary");
        continue;
      }
      delete this.verb_lookup[verb];
      delete this.verbs[verb];
      this.disabled_verbs.push(disabled_verbs[i]);
    }
  };
})();