// 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]);
}
return foundObjects;
};
})();