// debug.js
(function () {
/*global adventurejs A*/
var p = adventurejs.Game.prototype;
/**
* Prep the supplied string for printing to the display.
* @method adventurejs.Game#debug
* @memberOf adventurejs.Game
* @param {String} token
*/
p.debug = function Game_print(msg) {
if (!this.game.settings.print_debug_messages) return;
if (!msg) return;
let token_array = msg.split("|").map((token) => token.trim());
if (token_array.length > 1) {
msg = '<em class="debug">';
for (var i = 0; i < token_array.length; i++) {
msg += "<span class='debug_" + i + "'>" + token_array[i] + "</span> ";
}
msg += "</em>";
}
// send to display
if (msg) {
this.game.log(
token_array[0],
"log",
"high",
`${token_array[1]} > ${token_array[2]}`,
"Debug"
);
this.display.print(msg, "debug");
}
};
})();