import { patchDHWeapon, patchIkonisLogic, patchDhCharacter, seedIkonisHomebrew, registerIkonisFeatures } from './ikonis-data.js'; import { patchIkonisSheet } from './ikonis-sheet.js'; const MODULE_ID = 'dh-ikonis'; Hooks.once('init', () => { console.log(`${MODULE_ID} | Initializing Ikonis Module`); // Register default features in CONFIG immediately registerIkonisFeatures(); // --- Slot Settings --- [1, 2, 3, 4].forEach(tier => { game.settings.register(MODULE_ID, `slotsTier${tier}`, { name: `Slots at Tier ${tier}`, hint: `How many augment slots a weapon gets at Tier ${tier}.`, scope: "world", config: true, type: Number, default: tier + 1 }); }); // Toggle for Tech Rename game.settings.register(MODULE_ID, "enableTechRename", { name: "Rename Magic to Tech", hint: "Renames 'Magical' damage to 'Tech' damage and updates the icon to a microchip.", scope: "world", config: true, type: Boolean, default: true }); // Toggle for Currency Override game.settings.register(MODULE_ID, "enableCurrencyOverride", { name: "Enable Quantum Currency", hint: "Automatically overrides homebrew settings to use 'Quantum' credits and atomic icons.", scope: "world", config: true, type: Boolean, default: true }); const DhCharacter = CONFIG.Actor.dataModels?.character; if (DhCharacter) patchDhCharacter(DhCharacter); }); Hooks.on('setup', () => { // Damage Type Rename if (game.settings.get(MODULE_ID, "enableTechRename")) { const mag = CONFIG.DH?.GENERAL?.damageTypes?.magical; if (mag) { mag.label = "Tech"; mag.abbreviation = "TCH"; mag.icon = "fa-solid fa-microchip"; } } patchDHWeapon(); patchIkonisLogic(); patchIkonisSheet(); }); Hooks.once('ready', async () => { console.log(`${MODULE_ID} | Ready.`); if (game.user.isGM) { // Seed default Ikonis features into native Homebrew if missing await seedIkonisHomebrew(); if (game.settings.get(MODULE_ID, "enableCurrencyOverride")) { await overrideCurrency(); } } const DhCharacter = game.system.api?.models?.actors?.DhCharacter || CONFIG.Actor.dataModels?.character; if (DhCharacter) patchDhCharacter(DhCharacter); }); async function overrideCurrency() { let key = 'Homebrew'; if (!game.settings.settings.has('daggerheart.Homebrew')) { if (game.settings.settings.has('daggerheart.homebrew')) key = 'homebrew'; else return; } const homebrew = game.settings.get('daggerheart', key); if (!homebrew || homebrew.currency?.title === "Quantum") return; const newHomebrew = (typeof homebrew.toObject === 'function') ? homebrew.toObject() : foundry.utils.deepClone(homebrew); newHomebrew.currency = { title: "Quantum", coins: { enabled: true, label: "Quantum", icon: "fa-solid fa-atom" }, handfuls: { enabled: false, label: "Handfuls", icon: "fa-solid fa-coins" }, bags: { enabled: false, label: "Bags", icon: "fa-solid fa-sack" }, chests: { enabled: false, label: "Chests", icon: "fa-solid fa-treasure-chest" } }; await game.settings.set('daggerheart', key, newHomebrew); console.log(`${MODULE_ID} | Currency system updated to Quantum Credits.`); }