// selectNotPlayerParent.js
(function() {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Parser.prototype;
/**
* Exclude from a list of assets all assets that are nested in player.
* @method adventurejs.Parser#selectNotPlayerParent
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectNotPlayerParent = function Parser_selectNotPlayerParent(list)
{
if("string" === typeof list) list = [list];
if( !Array.isArray( list ) )
{
this.game.log( "warn", "critical", "selectNotPlayerParent.js > received non-array", 'Parser' );
return [];
}
var foundObjects = [];
for(var i = 0; i < list.length; i++)
{
var object = this.game.getAsset( list[i] );
var player = this.game.getPlayer();
var currentRoom = this.game.getCurrentRoom();
if( player.isNested()
&& object.id === player.getNestId() )
{
continue;
}
if( false === player.isNested()
&& object.id === currentRoom.id )
{
continue;
}
if( player.isNested()
&& object.id === currentRoom.id
&& player.getNestAsset() instanceof adventurejs.Floor )
{
continue;
}
foundObjects.push( list[i] );
}
return foundObjects;
}
}());