Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// getVerbConnections.js
(function () {
  /*global adventurejs A*/
  var p = adventurejs.Asset.prototype;
  /**
   * Return an array of asset ids connected to this
   * asset via the specified verb.
   * @memberOf adventurejs.Asset
   * @method adventurejs.Asset#getVerbConnections
   * @param {String} verb The name of a verb.
   * @param {String} to_ov Connection to direct or indirect objects of verb.
   * @return {Array}
   */
  p.getVerbConnections = function Asset_getConnections(verb, to_ov) {
    if (
      !verb ||
      !this.game.dictionary.verbs[verb] ||
      !this.is.connected_by ||
      !this.is.connected_by[verb]
    ) {
      return [];
    }

    if (to_ov === "dov" && this.isIOV(verb)) to_ov = "to_dov";
    if (to_ov === "iov" && this.isDOV(verb)) to_ov = "to_iov";

    if (to_ov !== "to_dov" && to_ov !== "to_iov") {
      if (this.isDOV(verb)) to_ov = "to_iov";
      else if (this.isIOV(verb)) to_ov = "to_dov";
    }

    return this.is.connected_by[verb][to_ov] || [];
  };
})();