feat: rename augments and register default features to system configuration on init

This commit is contained in:
CPTN Cosmo 2026-04-26 19:29:16 +02:00
parent e77007a29b
commit 80d2d95617
2 changed files with 28 additions and 6 deletions

View file

@ -1,14 +1,33 @@
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" }
{ id: "force", name: "Force", effect: "+1 Damage on Melee attacks.", cost: "Cost: 2 Iron" },
{ id: "fire", name: "Fire", effect: "Deals Fire damage instead of Physical.", cost: "Cost: 1 Blaze Glass" },
{ id: "shield", name: "Shield", effect: "+1 Armor while equipped.", cost: "Cost: 2 Steel" },
{ id: "range", name: "Range", effect: "Increases Range by 1 step.", cost: "Cost: 1 Lens" }
];
// Global caches for resolved features to keep getters fast
const _featureCache = new Map();
/**
* Injects Ikonis defaults directly into the system configuration.
*/
export function registerIkonisFeatures() {
if (!CONFIG.DH?.ITEM?.weaponFeatures) return;
for (const aug of DEFAULT_AUGMENTS) {
const nativeId = `ikonis-${aug.id}`;
CONFIG.DH.ITEM.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: []
};
}
console.log("DH-Ikonis | Features registered in CONFIG.");
}
/**
* Seeds the Daggerheart Homebrew settings with Ikonis defaults if they don't exist.
*/
@ -17,7 +36,7 @@ export async function seedIkonisHomebrew() {
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 = {};

View file

@ -1,4 +1,4 @@
import { patchDHWeapon, patchIkonisLogic, patchDhCharacter, seedIkonisHomebrew } from './ikonis-data.js';
import { patchDHWeapon, patchIkonisLogic, patchDhCharacter, seedIkonisHomebrew, registerIkonisFeatures } from './ikonis-data.js';
import { patchIkonisSheet } from './ikonis-sheet.js';
const MODULE_ID = 'dh-ikonis';
@ -6,6 +6,9 @@ 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}`, {