feat: add seedIkonisHomebrew function to automatically populate default augment blueprints into Daggerheart Homebrew settings

This commit is contained in:
CPTN Cosmo 2026-04-26 19:25:16 +02:00
parent 6cfadbc1ac
commit e77007a29b
2 changed files with 49 additions and 3 deletions

View file

@ -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: `<p>${aug.effect}</p><p>${aug.cost}</p>`,
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.

View file

@ -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;