// selectCarried.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not carried by player.
* @method AdventureJS.Parser#selectCarried
* @memberOf AdventureJS.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectCarried = function Parser_selectCarried(list) {
if (typeof list !== "object") {
this.game.log(
"L1561",
"error",
"critical",
[`[selectCarried.js] selectCarried() received non-array,`, list],
"Parser"
);
return [];
}
var foundObjects = [];
var dispensers = [];
for (var i = 0; i < list.length; i++) {
console.log("selectCarried list[i]", list[i]);
var object = this.game.getAsset(list[i]);
if (object.isWithin(this.game.getPlayer())) {
foundObjects.push(list[i]);
continue;
}
}
this.game.log(
"L1645",
"log",
"high",
`[selectCarried.js] selectCarried() return:\n${foundObjects}`,
"Parser"
);
return foundObjects;
};
})();