Pre-release
Adventure.js Docs Downloads
Score: 0 Moves: 0
// getPrintableListOfContents.js
(function () {
  /*global adventurejs A*/
  "use strict";
  var p = adventurejs.Tangible.prototype;
  /**
   * Get a printable list of assets within all
   * Aspects of this asset, for example
   * to append to asset description when player inputs
   * "examine this". Returns a string.
   * @memberOf adventurejs.Tangible
   * @method adventurejs.Tangible#getPrintableListOfContents
   * @param {Object} params
   * @returns {String}
   */
  p.getPrintableListOfContents =
    function Tangible_getPrintableListOfFullContents(params) {
      this.game.log(
        "log",
        "high",
        "Tangible.js > " + this.id + " getPrintableListOfContents",
        "Tangible"
      );
      if (!params) {
        params = {};
      }
      if (!params.caller) {
        params.caller = "examine";
      }
      var output = "";

      for (var aspect in this.aspects) {
        if (!this.hasAspectAt(aspect)) {
          continue;
        }
        if (!this.aspects[aspect].list_in_room) {
          if (this.aspects[aspect].know_with_parent) {
            this.setAspectContentsKnown(aspect);
          }
        } else if (
          this.aspects[aspect].contents.length > 0 ||
          this.aspects[aspect].vessel.class
        ) {
          output += this.getPrintableListOfContentsAt(aspect, params);
        }
      }
      return output;
    };
})();