// 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>`;
let exits = this.game.renderPlaceholders(this.game.getRoomExits());
exits = `<div class="ajs-p">${exits}</div>`;
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;
// print contents & exits
if (widget.print_room_contents && widget.print_contents_before_exits)
html += contents;
if (widget.print_room_exits) html += exits;
if (widget.print_room_contents && !widget.print_contents_before_exits)
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;
});
};
})();