// selectCharacter.js
(function () {
/* global adventurejs A */
var p = adventurejs.Parser.prototype;
/**
* Exclude from a list of assets all assets that are not characters.
* @method adventurejs.Parser#selectCharacter
* @memberOf adventurejs.Parser
* @param {Array} list
* @returns {Array}
*/
p.selectCharacter = function Parser_selectCharacter(list) {
if ("string" === typeof list) list = [list];
if (!Array.isArray(list)) {
this.game.log(
"L1562",
"error",
"critical",
[`[selectCharacter.js] selectCharacter() received non-array,`, list],
"Parser"
);
return [];
}
this.game.log(
"L1149",
"log",
"high",
`[selectCharacter.js] selectCharacter() receive:\n${list}`,
"Parser"
);
var foundObjects = [];
for (var i = 0; i < list.length; i++) {
var object = this.game.getAsset(list[i]);
if (object instanceof adventurejs.Character) {
foundObjects.push(list[i]);
}
}
return foundObjects;
};
})();