import { patchDHWeapon, DEFAULT_AUGMENTS } from './ikonis-data.js'; import { patchIkonisSheet } from './ikonis-sheet.js'; import { IkonisAugmentConfig } from './ikonis-config.js'; const MODULE_ID = 'dh-ikonis'; Hooks.once('init', () => { console.log(`${MODULE_ID} | Initializing Ikonis Module`); // Global Augments List game.settings.register(MODULE_ID, "augmentsList", { scope: "world", config: false, type: Array, default: DEFAULT_AUGMENTS }); // Default Bonded Feature game.settings.register(MODULE_ID, "defaultBondedUuid", { scope: "world", config: false, type: String, default: "" }); // Slot Scaling for Tiers 1, 2, 3, 4 [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 >= 2 ? 3 : 2 }); }); // Configuration Menu (V2 compliant) game.settings.registerMenu(MODULE_ID, "augmentsMenu", { name: "Manage Ikonis Augments", label: "Open Augment Manager", hint: "Add, remove, or edit the global list of Ikonis augments.", icon: "fa-solid fa-microchip", type: class extends foundry.applications.api.ApplicationV2 { render() { IkonisAugmentConfig.open(); return this; } }, restricted: true }); }); Hooks.on('setup', () => { patchDHWeapon(); patchIkonisSheet(); }); // Watch for Tier changes and force a refresh Hooks.on('updateItem', (item, changes, options, userId) => { // Check if system data or flags were updated const isTierUpdate = foundry.utils.hasProperty(changes, "system.tier"); const isFlagUpdate = foundry.utils.hasProperty(changes, "flags.dh-ikonis"); if (isTierUpdate || isFlagUpdate) { console.log(`DH-Ikonis | Update detected for ${item.name}. Re-rendering sheets...`); // Find all active sheets for this item and force a full render Object.values(item.apps || {}).forEach(app => { if (app.render) app.render(true); }); } }); Hooks.once('ready', () => { const actorsApi = game.system.api.models.actors || {}; const DhCharacter = actorsApi.DhCharacter || actorsApi.DHCharacter || actorsApi.character; if (DhCharacter) { Object.defineProperty(DhCharacter.prototype, 'primaryWeapon', { get: function() { return this.parent.items.find(x => x.type === 'weapon' && x.system.equipped && !x.system.secondary); }, configurable: true }); Object.defineProperty(DhCharacter.prototype, 'secondaryWeapon', { get: function() { return this.parent.items.find(x => x.type === 'weapon' && x.system.equipped && x.system.secondary); }, configurable: true }); } });