// selectNotParent.js
(function () {
/* global adventurejs A */
var p = adventurejs.Parser.prototype;
/**
* Exclude the subject's parent from a list of assets.
* @method adventurejs.Parser#selectNotParent
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectNotParent = function Parser_selectNotParent(list) {
if ("string" === typeof list) list = [list];
if (!Array.isArray(list)) {
this.game.log(
"L1281",
"error",
"critical",
["[selectNotParent.js] selectNotParent() received non-array", list],
"Parser"
);
return [];
}
this.game.log(
"L1153",
"log",
"high",
`[selectNotParent.js] selectNotParent() receive:\n${list}`,
"Parser"
);
var foundObjects = [];
var input = this.game.getInput();
var player = this.game.getPlayer();
var subject = input.getSubject();
var room = this.game.getRoom();
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 === room.id) {
continue;
}
if (
subject.isNested() &&
object.id === room.id &&
subject.getNestAsset() instanceof adventurejs.Floor
) {
continue;
}
foundObjects.push(list[i]);
}
return foundObjects;
};
})();