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

/* global adventurejs A */

/**
 * Get a list of recently referred assets. Not currently
 * used but intended as a utility method to help with
 * disambiguation. To use call A.getRecentAssets.call(this.game)
 * @method adventurejs.Game#getRecentAssets
 * @memberOf adventurejs.Game
 * @returns {Object}
 */
adventurejs.getRecentAssets = function Adventurejs_getRecentAssets() {
  let i = 0;
  let assets = [];
  while (i < 5) {
    let input = this.game.parser.input_history[i];
    if ("undefined" === typeof input) break;
    for (let j = 1; j < 4; j++) {
      let asset = input.getAsset(j);
      if (asset) assets.push(asset.id);
    }
    i++;
  }
  return assets;
};