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