Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// isConnectedToAnything.js
(function () {
  /*global adventurejs A*/
  var p = adventurejs.Asset.prototype;
  /**
   * Check whether this asset is currently connected to anything
   * by a verb such as <code class="property">plugIn</code>
   * or <code class="property">tie</code>. For example, if this asset
   * is a computer plugged into an outlet, this method would return true.
   * @memberOf adventurejs.Asset
   * @method adventurejs.Asset#isConnectedToAnything
   * @param {String} verb The name of a verb.
   * @param {String} to_ov Direct or indirect object of verb.
   * @return {Boolean}
   */
  p.isConnectedToAnything = function Asset_isConnectedToAnything(verb, to_ov) {
    if (
      !verb ||
      !this.game.dictionary.verbs[verb] ||
      !this.is.connected_by ||
      !this.is.connected_by[verb]
    )
      return false;

    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]?.length ? true : false;
  };
})();