Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// IOVisConnectedToAsset.js
(function() {
	/*global adventurejs A*/ 
  "use strict";
  var p = adventurejs.Asset.prototype;	
  /**
   * Check whether this asset is currently connected as an indirect
   * object to the specified direct object by the specified verb.
   * For example, in the case of a computer plugged into an outlet, 
   * the outlet would be the indirect object, and calling this method 
   * on it would return true.
   * @memberOf adventurejs.Asset
	 * @method adventurejs.Asset#IOVisConnectedToAsset
   * @param {String} verb The name of the verb to test.
   * @param {Object|String} asset A game asset or asset id to test.
   * @return {Boolean}
   */
  p.IOVisConnectedToAsset = function Asset_IOVisConnectedToAsset(verb,asset) 
  { 
    if( "string" === typeof asset) asset = this.game.getAsset( asset );
    if( !asset || !asset.id ) return false;
    if( !verb || !this.game.dictionary.verbs[verb] ) return false;
    if( !this.iov[verb]?.with_params.connections
      || -1 === this.iov[verb].with_params.connections.indexOf( asset.id ) )
      {
        return false;
      }
    return true;
  }
}());