// selectNotPlayerParent.js
(function () {
/*global adventurejs A*/
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(
"L1281",
"warn",
"critical",
"selectNotPlayerParent.js > received non-array",
"Parser"
);
return [];
}
var foundObjects = [];
var player = this.game.getPlayer();
var currentRoom = this.game.getCurrentRoom();
for (var i = 0; i < list.length; i++) {
var object = this.game.getAsset(list[i]);
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;
};
})();