// selectSelf.js
(function () {
/* global adventurejs A */
var p = adventurejs.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not the
* subject of this turn's input. By default this is
* the player, but may be an NPC in cases like "Floyd, go east".
* @method adventurejs.Parser#selectSelf
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectSelf = function Parser_selectSelf(list) {
if ("string" === typeof list) list = [list];
if (!Array.isArray(list)) {
this.game.log(
"L1397",
"error",
"critical",
["[selectSelf.js] selectSelf() received non-array", list],
"Parser"
);
return [];
}
this.game.log(
"L1333",
"log",
"high",
`[selectSelf.js] selectSelf() receive:\n${list}`,
"Parser"
);
var input = this.game.getInput();
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( "selectSelf returned " + JSON.stringify(foundObjects) );
return foundObjects;
};
})();