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

  p.setVerbWithClass = function Asset_setVerbWithClass(verb, Class, ov) {
    if (!ov || (ov !== "dov" && ov !== "iov")) ov = "dov";
    if (!verb || !this.game.dictionary.verbs[verb]) return false;
    // @TODO case check / lookup
    let c = AdventureJS[Class] || AdventureJS.Assets[Class];
    if (!c) 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(Class)) {
      this[ov][verb].with_classes.push(Class);
    }
    return true;
  };
})();