Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// setVerbWithClass.js
(function () {
  /*global adventurejs A*/
  var p = adventurejs.Asset.prototype;
  /**
   * <strong>setVerbWithClass</strong> is a method to add an indirect object
   * class to asset.dov[verb].with_classes.
   * @memberOf adventurejs.Asset
   * @method adventurejs.Asset#setVerbWithClass
   * @param {String} verb The name of a verb.
   * @param {String} klass
   * @param {String} ov Direct or indirect object of verb.
   * @returns {Boolean}
   */

  p.setVerbWithClass = function Asset_setVerbWithClass(verb, klass, ov) {
    if (!ov || (ov !== "dov" && ov !== "iov")) ov = "dov";
    if (!verb || !this.game.dictionary.verbs[verb]) return false;
    if (!adventurejs[klass]) return false;
    if (!this["is" + ov.toUpperCase()](verb)) {
      // isDOV isIOV
      this["set" + ov.toUpperCase()](verb); // setDOV setIOV
    }
    if (-1 === this[ov][verb].with_classes.indexOf(klass)) {
      this[ov][verb].with_classes.push(klass);
    }
    return true;
  };
})();