Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0
// selectDOV.js

(function () {
  /* global adventurejs A */

  var p = adventurejs.Parser.prototype;

  /**
   * Exclude from a list of assets all assets that are not direct objects of verb.
   * @method adventurejs.Parser#selectDOV
   * @memberOf adventurejs.Parser
   * @param {Array} list
   * @returns {Array}
   */
  p.selectDOV = function Parser_selectDOV(list, verb) {
    if (typeof list !== "object") {
      this.game.log(
        "L1563",
        "error",
        "critical",
        [`[selectDOV.js] selectDOV() received non-array,`, list],
        "Parser"
      );
      return [];
    }
    this.game.log(
      "L1134",
      "log",
      "high",
      `[selectDOV.js] selectDOV() receive:\n${list}`,
      "Parser"
    );
    var foundObjects = [];
    for (var i = 0; i < list.length; i++) {
      console.log("selectDOV list[i]", list[i]);
      var object = this.game.getAsset(list[i]);
      if (object.isDOV(verb)) {
        foundObjects.push(list[i]);
      }
    }
    return foundObjects;
  };
})();