// selectGlobalSubstance.js
(function () {
/* global AdventureJS A */
var p = AdventureJS.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not global substances.
* @method AdventureJS.Parser#selectGlobalSubstance
* @memberOf AdventureJS.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectGlobalSubstance = function Parser_selectGlobalSubstance(list) {
if (typeof list !== "object") {
this.game.log(
"L1564",
"error",
"critical",
[
`[selectGlobalSubstance.js] selectGlobalSubstance() received non-array,`,
list,
],
"Parser"
);
return [];
}
this.game.log(
"L1138",
"log",
"high",
`[selectGlobalSubstance.js] selectGlobalSubstance() receive:\n${list}`,
"Parser"
);
var foundObjects = [];
for (var i = 0; i < list.length; i++) {
var object = list[i];
if (object.includes(":")) {
// discard substance-in-tangible
continue;
} else {
object = this.game.getAsset(list[i]);
}
if (object instanceof AdventureJS.Assets.Substance) {
foundObjects.push(list[i]);
}
}
this.game.log(
"L1649",
"log",
"high",
`[selectGlobalSubstance.js] selectGlobalSubstance() return:\n${foundObjects}`,
"Parser"
);
return foundObjects;
};
})();