// printCurrentRoom.js
(function () {
/*global adventurejs A*/
"use strict";
var p = adventurejs.Game.prototype;
/**
* Print room description to game display.
* Includes input, room name, and room description.
* 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">printCurrentRoom( { verbose: true } )</pre>
* @method adventurejs.Game#printCurrentRoom
* @memberOf adventurejs.Game
* @param {Object} params
* @todo Formalize handling for description/brief/verbose descriptions
*/
p.printCurrentRoom = function Game_printCurrentRoom(
params = { verbose: false }
) {
this.game.log("log", 1, "Game.printCurrentRoom", "Game");
// if( "undefined" === typeof params ) params = {};
// if( "undefined" === typeof params.verbose ) params.verbose = false;
var currentRoom = this.world[this.world._currentRoom];
var desc = "description";
var v = this.settings.verbosity;
// first print room name
this.print(currentRoom.name, "room_name");
// first visit or params.verbose=true used by look / examine
if (
params.verbose ||
(!currentRoom.is.seen &&
this.settings.print_verbose_room_descriptions_on_first_visit)
) {
v = 1;
}
// try to choose a description based on verbosity setting
// ensure that author has written something
if (1 === v && !currentRoom.descriptions.verbose) v = 0;
if (-2 === v && !currentRoom.descriptions.briefer) v = -1;
if (-1 === v && !currentRoom.descriptions.brief) v = 0;
switch (v) {
case -2:
desc = "briefer";
break;
case -1:
desc = "brief";
break;
case 1:
desc = "verbose";
break;
default:
desc = "look";
break;
}
if (!currentRoom.descriptions[desc]) desc = "look";
this.print(
A.getSAF.call(this, currentRoom.descriptions[desc], currentRoom),
"room_description"
);
this.printCurrentRoomExits();
this.printCurrentRoomContents();
return this;
};
})();