// selectHeld.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not being held by player.
* @method adventurejs.Parser#selectHeld
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectHeld = function Parser_selectHeld(list)
{
if("string" === typeof list) list = [list];
if( !Array.isArray( list ) )
{
this.game.log( "warn", "critical", "selectHeld.js > received non-array", 'Parser' );
return [];
}
var player = this.game.getPlayer();
var foundObjects = [];
for(var i = 0; i < list.length; i++)
{
var object = this.game.getAsset( list[i] );
if( player.IOVisConnectedToAsset('hold',object) )
{
foundObjects.push( list[i] );
}
}
//console.warn( "selectHeld returned " + foundObjects );
return foundObjects;
}
}());