Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// DOVisConnectedToAsset.js
(function() {
	/*global adventurejs A*/ 
  "use strict";
  var p = adventurejs.Asset.prototype;	
  /**
   * Check whether this asset is currently connected as a direct
   * object to the specified indirect object by the specified verb.
   * For example, in the case of a computer plugged into an outlet, 
   * the computer would be the direct object, and calling this method 
   * on it would return true.
   * @memberOf adventurejs.Asset
	 * @method adventurejs.Asset#DOVisConnectedToAsset
   * @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.DOVisConnectedToAsset = function Asset_DOVisConnectedToAsset(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.dov[verb]?.with_params.connections
      && -1 !== this.dov[verb].with_params.connections.indexOf(asset.id) )
      {
        return true;
      }    
    return false;
  }
}());