Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// 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 (typeof list !== "object") {
      console.warn("selectCharacter received non-array", list);
      return [];
    }
    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]);
      }

      // TODO sentient vs non-sentient characters?
    }
    return foundObjects;
  };
})();