// selectReservoirIfSubstance.js
(function () {
/* global adventurejs A */
var p = adventurejs.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not
* substance reservoirs such as a lake or a beach, only if
* a substance was specified.
* @method adventurejs.Parser#selectReservoirIfSubstance
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectReservoirIfSubstance = function Parser_selectReservoirIfSubstance(
list
) {
if ("string" === typeof list) list = [list];
if (!Array.isArray(list)) {
this.game.log(
"L1249",
"error",
"critical",
[
"[selectReservoirIfSubstance.js] selectReservoirIfSubstance() received non-array",
list,
],
"Parser"
);
return [];
}
this.game.log(
"L1248",
"log",
"high",
`[selectReservoirIfSubstance.js] selectReservoirIfSubstance() receive: ${list}`,
"Parser"
);
var foundObjects = [];
for (var i = 0; i < list.length; i++) {
var split = list[i].split(":");
if (split.length === 1) {
foundObjects.push(list[i]);
continue;
}
var object;
object = this.game.getAsset(list[i]);
if (object.$is("reservoir")) {
foundObjects.push(list[i]);
continue;
}
}
this.game.log(
"L1250",
"log",
"high",
`[selectReservoirIfSubstance.js] returns {String(foundObjects)}`,
"Parser"
);
return foundObjects;
};
})();