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

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

  var p = adventurejs.Game.prototype;

  /**
   * Print room description to game display.
   * Includes input, room name, and room description.
   * Defaults to current room, but can accept a room param.
   * Calling the function with params.verbose set to true
   * will override global verbosity settings and try to
   * print a verbose description.
   * <br><br>
   * For example:
   * <pre class="code">printRoom( { verbose: true } )</pre>
   * @method adventurejs.Game#printRoom
   * @memberOf adventurejs.Game
   * @param {Object} params
   * @todo Formalize handling for description/brief/verbose descriptions
   */
  p.printRoom = function Game_printRoom(params = {}) {
    this.game.log(
      "L1083",
      "log",
      1,
      `[printRoom.js] print ${this.world._room} description`,
      "Game"
    );

    const {
      first = false,
      verbose = false,
      room = this.game.world[this.game.world._room],
    } = params;

    this.game.print(this.game.getRoomDescription(params));

    if (
      (room.print_room_exits ||
        (room.print_room_exits !== false &&
          this.game.settings.print_room_exits)) &&
      !room.is.dark
    ) {
      this.game.print(this.game.getRoomExits());
    }

    if (
      (room.print_room_contents ||
        (room.print_room_contents !== false &&
          this.game.settings.print_room_contents)) &&
      !room.is.dark
    ) {
      this.game.print(this.game.getRoomContents());
    }

    return this;
  };
})();