Pre-release
AdventureJS Docs Downloads Bundler Devlog Score: 0 Moves: 0
// updateRoomDescriptionWidgets.js

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

  var p = AdventureJS.Display.prototype;

  /**
   * Update room description widgets.
   * @method AdventureJS.Display#updateRoomDescriptionWidgets
   * @param {Object} properties
   */
  p.updateRoomDescriptionWidgets =
    function Display_updateRoomDescriptionWidgets(properties) {
      if (this.room_description_widgets.length === 0) return;
      const room = this.game.world[this.game.world._room];

      const name = this.game.getRoomName(room);

      let description = this.game.renderPlaceholders(
        this.game.getRoomDescription({ name: false })
      );
      description = `<div class="ajs-p">${description}</div>`;

      // if (this.game.settings.include_exits_in_room_widgets) {
      let exits = this.game.renderPlaceholders(this.game.getRoomExits());
      exits = `<div class="ajs-p">${exits}</div>`;
      // }

      // if (this.game.settings.include_contents_in_room_widgets) {
      let contents = this.game.renderPlaceholders(
        this.game.getPrintableRoomContents()
      );
      contents = `<div class="ajs-p">${contents}</div>`;
      // }

      this.room_description_widgets.forEach(function (widget) {
        let html = "";
        if (widget.print_name) html += name;
        html += description;
        if (widget.print_exits) html += exits;
        if (widget.print_contents) html += contents;
        html = `
        <div class="ajs-inner ajs-scroll-container">
          <div class="ajs-scroll-content">
            <div class="ajs-room-description-container">
              ${html}
            </div>
          </div>
        </div>
      `;
        widget.innerHTML = html;
      });
    };
})();