diff --git a/scripts/ikonis-data.js b/scripts/ikonis-data.js index 3902cc5..490275d 100644 --- a/scripts/ikonis-data.js +++ b/scripts/ikonis-data.js @@ -7,6 +7,7 @@ export const DEFAULT_AUGMENTS = [ img: "icons/magic/control/debuff-energy-hold-blue-yellow.webp", effects: [ { + _id: "ikonisBondedEff", name: "Ikonis: Bonded", type: "base", img: "icons/magic/control/debuff-energy-hold-blue-yellow.webp", @@ -55,7 +56,7 @@ const _featureCache = new Map(); */ export function registerIkonisFeatures() { if (!CONFIG.DH?.ITEM?.weaponFeatures) return; - + console.log("DH-Ikonis | Registering features in CONFIG..."); for (const aug of DEFAULT_AUGMENTS) { const nativeId = `ikonis-${aug.id}`; CONFIG.DH.ITEM.weaponFeatures[nativeId] = { @@ -75,8 +76,19 @@ export function registerIkonisFeatures() { export async function seedIkonisHomebrew() { if (!game.user.isGM) return; - const homebrewKey = game.settings.settings.has('daggerheart.Homebrew') ? 'Homebrew' : 'homebrew'; - const homebrew = foundry.utils.deepClone(game.settings.get('daggerheart', homebrewKey) || {}); + let homebrewKey = 'Homebrew'; + if (!game.settings.settings.has('daggerheart.Homebrew')) { + if (game.settings.settings.has('daggerheart.homebrew')) homebrewKey = 'homebrew'; + else { + console.warn("DH-Ikonis | Daggerheart Homebrew setting not found."); + return; + } + } + + const current = game.settings.get('daggerheart', homebrewKey) || {}; + const homebrew = (typeof current.toObject === 'function') ? current.toObject() : foundry.utils.deepClone(current); + + console.log(`DH-Ikonis | Seeding homebrew features (key: ${homebrewKey})...`); if (!homebrew.itemFeatures) homebrew.itemFeatures = { weaponFeatures: {}, armorFeatures: {} }; if (!homebrew.itemFeatures.weaponFeatures) homebrew.itemFeatures.weaponFeatures = {}; @@ -85,10 +97,13 @@ export async function seedIkonisHomebrew() { for (const aug of DEFAULT_AUGMENTS) { const nativeId = `ikonis-${aug.id}`; const existing = homebrew.itemFeatures.weaponFeatures[nativeId]; + + // We update if it's missing OR if it's an Ikonis feature that needs an update (like Bonded getting effects) const hasEffects = aug.effects && aug.effects.length > 0; const needsUpdate = !existing || (hasEffects && (!existing.effects || existing.effects.length === 0)); if (needsUpdate) { + console.log(`DH-Ikonis | Seeding/Updating feature: ${aug.name}`); homebrew.itemFeatures.weaponFeatures[nativeId] = { name: `Ikonis: ${aug.name}`, img: aug.img || "systems/daggerheart/assets/icons/documents/items/chip.svg", @@ -103,6 +118,8 @@ export async function seedIkonisHomebrew() { if (updates) { await game.settings.set('daggerheart', homebrewKey, homebrew); console.log("DH-Ikonis | Default blueprints seeded into Homebrew settings."); + } else { + console.log("DH-Ikonis | Homebrew features are already up to date."); } }