// getExtendedExitName.js
(function () {
/* global adventurejs A */
var p = adventurejs.Game.prototype;
/**
*
* @method adventurejs.Game#getExtendedExitName
* @memberOf adventurejs.Game
* @param {Object} exit
* @param {Object} destination
* @returns {String}
*/
p.getExtendedExitName = function Game_getExtendedExitName(exit, destination) {
// add the direction
var output = `<span class="ajs-exit-direction">${exit.direction}</span>`;
var player = this.game.getPlayer();
var preposition = " to ";
var definite_article = destination.definite_article;
var destName = destination.name; //destination.name;
var addDest = true;
var room = this.game.getRoom();
var settings = this.settings;
// test conditions that may prevent printing destination
if (
false === settings.show_room_names_in_exit_descriptions ||
false === room.show_room_names_in_exit_descriptions
) {
addDest = false;
}
if (
!player.knowsAbout(destination) &&
(settings.show_room_names_in_exit_descriptions_only_when_room_is_known ||
room.show_room_names_in_exit_descriptions_only_when_room_is_known)
) {
addDest = false;
}
if (
!exit.is.used &&
(settings.show_room_names_in_exit_descriptions_only_after_exit_has_been_used ||
room.show_room_names_in_exit_descriptions_only_after_exit_has_been_used)
) {
addDest = false;
}
if (addDest) {
output += `${preposition} ${definite_article ? definite_article + " " : ""}
<span class="ajs-exit-destination">${destName}</span>`;
}
return output;
};
})();