diff --git a/src/macros_new/gowlers-tracking-ledger/foundry.gowlershome.dyndns.org/modules/gowlers-tracking-ledger/scripts/gowlers-tracking-ledger.js b/src/macros_new/gowlers-tracking-ledger/foundry.gowlershome.dyndns.org/modules/gowlers-tracking-ledger/scripts/gowlers-tracking-ledger.js index a3534349..74bdd603 100644 --- a/src/macros_new/gowlers-tracking-ledger/foundry.gowlershome.dyndns.org/modules/gowlers-tracking-ledger/scripts/gowlers-tracking-ledger.js +++ b/src/macros_new/gowlers-tracking-ledger/foundry.gowlershome.dyndns.org/modules/gowlers-tracking-ledger/scripts/gowlers-tracking-ledger.js @@ -15,6 +15,33 @@ const SETTINGS_VERSION = 2; const COIN_ORDER = ["pp", "gp", "sp", "cp"]; const ENCOUNTER_FLAG = "pf1EncounterHistory"; const DAMAGE_DEALT_FLAG = "pf1DamageDealtHistory"; +const DEBUG_LOGS = false; +const HISTORY_PAGE_OPTIONS = [10, 20, 50, "all"]; + +const DAMAGE_ICON_MAP = { + slashing: { icon: "ra ra-sword", color: "#e3c000" }, + piercing: { icon: "ra ra-spear-head", color: "#2c7be5" }, + bludgeoning: { icon: "ra ra-large-hammer", color: "#e03131" }, + fire: { icon: "ra ra-fire", color: "#f76707" }, + cold: { icon: "ra ra-snowflake", color: "#3bc9db" }, + electricity: { icon: "ra ra-lightning-bolt", color: "#f0c419" }, + acid: { icon: "ra ra-round-bottom-flask", color: "#2f9e44" }, + sonic: { icon: "ra ra-megaphone", color: "#22b8cf" }, + force: { icon: "ra ra-crystal-ball", color: "#845ef7" }, + negative: { icon: "ra ra-skull", color: "#7950f2" }, + positive: { icon: "ra ra-sun", color: "#fab005" }, + healing: { icon: "ra ra-health", color: "#4caf50" }, + precision: { icon: "ra ra-target-arrows", color: "#000" }, + nonlethal: { icon: "ra ra-hand", color: "#000" }, + untyped: { icon: "ra ra-uncertainty", color: "#666" }, +}; + +const log = { + debug: (...args) => DEBUG_LOGS && console.debug("[GowlersTracking]", ...args), + info: (...args) => console.info("[GowlersTracking]", ...args), + warn: (...args) => console.warn("[GowlersTracking]", ...args), + error: (...args) => console.error("[GowlersTracking]", ...args), +}; const STAT_CONFIGS = { hp: { @@ -116,12 +143,12 @@ function setActiveHistoryTab(actorId, tabId) { // Global tab switching function for history dialog window.switchHistoryTab = function(tabId, el = null) { - console.log("[GowlersTracking] Tab switched to:", tabId); + log.debug("Tab switched to:", tabId); // Find the root element using the data-history-root attribute const root = el?.closest?.('[data-history-root]') ?? document.querySelector('[data-history-root]'); if (!root) { - console.warn("[GowlersTracking] History root element not found"); + log.warn("History root element not found"); return; } @@ -139,16 +166,16 @@ window.switchHistoryTab = function(tabId, el = null) { if (activeButton) { activeButton.classList.add('active'); - console.log("[GowlersTracking] Tab button activated:", tabId); + log.debug("Tab button activated:", tabId); } else { - console.warn("[GowlersTracking] Tab button not found for:", tabId); + log.warn("Tab button not found for:", tabId); } if (activePanel) { activePanel.style.display = 'block'; - console.log("[GowlersTracking] Tab panel displayed:", tabId); + log.debug("Tab panel displayed:", tabId); } else { - console.warn("[GowlersTracking] Tab panel not found for:", tabId); + log.warn("Tab panel not found for:", tabId); } const actorId = root?.getAttribute('data-history-root'); @@ -500,16 +527,15 @@ async function initializeModule() { } } - // Log detailed inspection for debugging - console.log("[GowlersTracking] Message inspection for damage details:"); - console.log("[GowlersTracking] - pf1Flags keys:", Object.keys(pf1Flags)); - console.log("[GowlersTracking] - Full metadata:", JSON.stringify(metadata, null, 2)); - console.log("[GowlersTracking] - message.rolls:", message.rolls?.length > 0 ? "Present" : "None"); - console.log("[GowlersTracking] - message.content length:", message.content?.length ?? 0); - - // Log HTML content snippet for analysis - if (message.content) { - console.log("[GowlersTracking] - HTML preview (first 1000 chars):", message.content.substring(0, 1000)); + if (DEBUG_LOGS) { + log.debug("Message inspection for damage details:"); + log.debug(" - pf1Flags keys:", Object.keys(pf1Flags)); + log.debug(" - Full metadata:", JSON.stringify(metadata, null, 2)); + log.debug(" - message.rolls:", message.rolls?.length > 0 ? "Present" : "None"); + log.debug(" - message.content length:", message.content?.length ?? 0); + if (message.content) { + log.debug(" - HTML preview (first 1000 chars):", message.content.substring(0, 1000)); + } } return { @@ -982,7 +1008,7 @@ function buildXpBreakdownTooltip(actor, xpEntry) { function buildHistoryContent(actor, tabArg) { const initialTab = tabArg ?? getActiveHistoryTab(actor.id, "hp"); // Explicitly capture the tab parameter - console.log("[GowlersTracking] buildHistoryContent called with initialTab:", initialTab); + log.debug("buildHistoryContent called with initialTab:", initialTab); setActiveHistoryTab(actor.id, initialTab); const canConfigure = game.user?.isGM; const configs = [ @@ -994,7 +1020,7 @@ function buildHistoryContent(actor, tabArg) { { label: "Timestamp", render: (entry) => formatDate(entry.timestamp) }, { label: "HP", render: (entry) => entry.value }, { - label: "Δ", + label: "Delta", render: (entry) => entry.diff, getTitle: (entry) => entry.damageBreakdown ? `${entry.damageBreakdown}` : "" }, @@ -1100,15 +1126,15 @@ function buildHistoryContent(actor, tabArg) { currentPage = totalPages; setHistoryPageState(actor.id, cfg.id, currentPage, rowsPerPage); } - const selectOptions = [10, 20, 50, "all"] + const selectOptions = HISTORY_PAGE_OPTIONS .map((value) => ``) .join(""); return `