// selectCarried.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not carried by player.
* @method adventurejs.Parser#selectCarried
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectCarried = function Parser_selectCarried(list)
{
if(typeof list !== "object" )
{
console.warn("selectCarried received non-array", list);
return [];
}
var foundObjects = [];
for(var i = 0; i < list.length; i++)
{
console.log("selectCarried list[i]", list[i] );
var object = this.game.getAsset( list[i] );
if( object.isIn( this.game.getPlayer() ) )
{
foundObjects.push( list[i] );
}
// TODO but is it nested in a closed object in player?
// and is it known? could be unseen inside an unopened thing
}
return foundObjects;
}
}());