diff --git a/scripts/ikonis-data.js b/scripts/ikonis-data.js index cf7f7be..88e8dd9 100644 --- a/scripts/ikonis-data.js +++ b/scripts/ikonis-data.js @@ -1,6 +1,47 @@ +export const DEFAULT_AUGMENTS = [ + { id: "bonded", name: "Bonded", effect: "Primary module for Ikonis hardware synchronization.", cost: "Cost: None" }, + { id: "force", name: "Kinetic Amplifier", effect: "+1 Damage on Melee attacks.", cost: "Cost: 2 Iron" }, + { id: "fire", name: "Thermal Core", effect: "Deals Fire damage instead of Physical.", cost: "Cost: 1 Blaze Glass" }, + { id: "shield", name: "Reactive Plating", effect: "+1 Armor while equipped.", cost: "Cost: 2 Steel" }, + { id: "range", name: "Long-Range Optics", effect: "Increases Range by 1 step.", cost: "Cost: 1 Lens" } +]; + // Global caches for resolved features to keep getters fast const _featureCache = new Map(); +/** + * Seeds the Daggerheart Homebrew settings with Ikonis defaults if they don't exist. + */ +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) || {}); + + if (!homebrew.itemFeatures) homebrew.itemFeatures = { weaponFeatures: {}, armorFeatures: {} }; + if (!homebrew.itemFeatures.weaponFeatures) homebrew.itemFeatures.weaponFeatures = {}; + + let updates = false; + for (const aug of DEFAULT_AUGMENTS) { + const nativeId = `ikonis-${aug.id}`; + if (!homebrew.itemFeatures.weaponFeatures[nativeId]) { + homebrew.itemFeatures.weaponFeatures[nativeId] = { + name: `Ikonis: ${aug.name}`, + img: "systems/daggerheart/assets/icons/documents/items/chip.svg", + description: `
${aug.effect}
${aug.cost}
`, + actions: {}, + effects: [] + }; + updates = true; + } + } + + if (updates) { + await game.settings.set('daggerheart', homebrewKey, homebrew); + console.log("DH-Ikonis | Default blueprints seeded into Homebrew settings."); + } +} + /** * Scans the Daggerheart system config for any weapon features starting with "Ikonis:". * These are treated as available augments for our slot system. diff --git a/scripts/main.js b/scripts/main.js index ad4cb36..a85cdf2 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -1,4 +1,4 @@ -import { patchDHWeapon, patchIkonisLogic, patchDhCharacter } from './ikonis-data.js'; +import { patchDHWeapon, patchIkonisLogic, patchDhCharacter, seedIkonisHomebrew } from './ikonis-data.js'; import { patchIkonisSheet } from './ikonis-sheet.js'; const MODULE_ID = 'dh-ikonis'; @@ -61,8 +61,13 @@ Hooks.on('setup', () => { Hooks.once('ready', async () => { console.log(`${MODULE_ID} | Ready.`); - if (game.user.isGM && game.settings.get(MODULE_ID, "enableCurrencyOverride")) { - await overrideCurrency(); + 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;