// selectNotWorn.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Parser.prototype;
/**
* Exclude from a list of assets all assets worn by player.
* @method AdventureJS.Parser#selectNotWorn
* @memberOf AdventureJS.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectNotWorn = function Parser_selectNotWorn(list) {
if ("string" === typeof list) list = [list];
if (!Array.isArray(list)) {
this.game.log(
"L1264",
"error",
"critical",
["[selectNotWorn.js] selectNotWorn() received non-array", list],
"Parser"
);
return [];
}
this.game.log(
"L1173",
"log",
"high",
`[selectNotWorn.js] selectNotWorn() receive:\n${list}`,
"Parser"
);
var foundObjects = [];
for (var i = 0; i < list.length; i++) {
var object = this.game.getAsset(list[i]);
// TODO worn by player vs worn by other character?
if (object.is.worn) {
continue;
}
foundObjects.push(list[i]);
}
this.game.log(
"L1669",
"log",
"high",
`[selectNotWorn.js] selectNotWorn() return:\n${foundObjects}`,
"Parser"
);
return foundObjects;
};
})();