// DOVsetWithAsset.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Asset.prototype;
/**
* <strong>DOVsetWithAsset</strong> is used to specify
* another asset that can be used as an indirect object with this
* asset as direct object. For example, if this asset is a locking
* chest, chest.DOVsetWithAsset('unlock', 'gold key') would add
* the gold key as an indirect object of the chest.
* @memberOf adventurejs.Asset
* @method adventurejs.Asset#DOVsetWithAsset
* @param {String} verb
* @param {Object} asset
* @returns {Boolean}
*/
p.DOVsetWithAsset = function Asset_DOVSetWithAsset(verb, asset)
{
if( !verb || !this.game.dictionary.verbs[verb] ) return false;
if( "string" === typeof asset ) asset = this.game.getAsset(asset);
if( !asset ) return false;
// verify that this is set as a direct object of verb
if(!this.isDOV(verb))
{
this.setDOV(verb);
}
// verify that indirect object isn't already set
if( -1 === this.dov[verb].with_assets.indexOf( asset.id ) )
{
this.dov[verb].with_assets.push( asset.id );
}
// that it works with an asset means it doesn't work with nothing
this.dov[verb].with_nothing = false;
return true;
}
}());