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