// 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(code, fx_or_type, content) {
code = code.trim();
fx_or_type = fx_or_type.trim();
content = content.trim();
// strip out .js
fx_or_type = fx_or_type.replace(".js", "");
let msg = "";
let hook = ["verbaction", "verbreaction", "verbphase"].includes(
fx_or_type.toLowerCase()
); // bool
// if it's a hook, that's our debug keyword
let keyword = hook ? fx_or_type.toLowerCase() : "general";
let type = hook ? "hook" : "debug";
// are we printing this keyword?
if (!this.game.settings.debug[keyword] && !this.game.settings.debug.all) {
return;
}
msg = `<span class="ajs-${type} ajs-${fx_or_type.toLowerCase()}">`;
msg += `<span class="_0">${hook ? fx_or_type : code}</span> `;
// if (
// type === "debug" &&
// this.game.settings.include_filename_in_debug ||
// "undefined" !== typeof this.game.dictionary.verbs[fx_or_type]
// )
if ("undefined" !== typeof this.game.dictionary.verbs[fx_or_type]) {
msg += `<span class="_1">[${fx_or_type}]</span> `;
}
msg += `<span class="_2">${content}</span> `;
msg += "</span>";
// print to display
this.display.print(msg, "ajs-debug");
};
})();