// selectWorn.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not worn by player.
* @method adventurejs.Parser#selectVisible
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectWorn = function Parser_selectWorn(list)
{
if("string" === typeof list) list = [list];
if( !Array.isArray( list ) )
{
this.game.log( "warn", "critical", "selectWorn.js > received non-array", 'Parser' );
return [];
}
var foundObjects = [];
for(var i = 0; i < list.length; i++)
{
var object = this.game.getAsset( list[i] );
if( !object.place ) continue;
var parent = object.getParentAsset();
if( !parent ) continue;
if( parent.id !== this.game.getPlayer().id ) continue;
if( !object.is.worn ) continue;
foundObjects.push( list[i] );
}
return foundObjects;
}
}());