// selectNotSelf.js
(function () {
/* global adventurejs A */
var p = adventurejs.Parser.prototype;
/**
* Exclude the subject of this
* turn's input from a list of assets. By default this is
* the player, but may be an NPC in cases like "Floyd, go east".
* @method adventurejs.Parser#selectNotSelf
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectNotSelf = function Parser_selectNotSelf(list) {
if ("string" === typeof list) list = [list];
if (!Array.isArray(list)) {
this.game.log(
"L1262",
"error",
"critical",
["[selectNotSelf.js] selectNotSelf() received non-array", list],
"Parser"
);
return [];
}
this.game.log(
"L1335",
"log",
"high",
`[selectNotSelf.js] selectNotSelf() receive:\n${list}`,
"Parser"
);
var input = this.game.getInput();
var player = this.game.getPlayer();
var subject = input.getSubject();
var foundObjects = [];
for (var i = 0; i < list.length; i++) {
var object = this.game.getAsset(list[i]);
if (!object) continue;
if (object.id === subject.id) continue;
foundObjects.push(list[i]);
}
//console.warn( "selectNotSelf returned " + JSON.stringify(foundObjects) );
return foundObjects;
};
})();