From 6cfadbc1ac66cdc8f76fe5a0590250ec44a427e4 Mon Sep 17 00:00:00 2001 From: cosmo Date: Sun, 26 Apr 2026 19:20:51 +0200 Subject: [PATCH] refactor: remove legacy augmentation configuration template and script files --- scripts/ikonis-config.js | 160 ------------------------------------ scripts/ikonis-data.js | 18 +--- templates/ikonis-config.hbs | 40 --------- 3 files changed, 3 insertions(+), 215 deletions(-) delete mode 100644 scripts/ikonis-config.js delete mode 100644 templates/ikonis-config.hbs diff --git a/scripts/ikonis-config.js b/scripts/ikonis-config.js deleted file mode 100644 index 0c7766e..0000000 --- a/scripts/ikonis-config.js +++ /dev/null @@ -1,160 +0,0 @@ -import { DEFAULT_AUGMENTS, getAttachedFeature } from './ikonis-data.js'; - -export class IkonisAugmentConfig { - static async open() { - const augments = game.settings.get('dh-ikonis', 'augmentsList') || DEFAULT_AUGMENTS; - const defaultBondedUuid = game.settings.get('dh-ikonis', 'defaultBondedUuid') || ""; - - const processedAugments = []; - for (const a of augments) { - const aug = { ...a }; - if (aug.featureUuid) { - const item = await getAttachedFeature(aug.featureUuid); - if (item) aug.featureName = item.name; - } - processedAugments.push(aug); - } - - let bondedName = ""; - if (defaultBondedUuid) { - const item = await getAttachedFeature(defaultBondedUuid); - if (item) bondedName = item.name; - } - - const template = "modules/dh-ikonis/templates/ikonis-config.hbs"; - const content = await foundry.applications.handlebars.renderTemplate(template, { augments: processedAugments, defaultBondedUuid, bondedName }); - - return foundry.applications.api.DialogV2.wait({ - window: { - title: "Global Hardware Manager", - icon: "fa-solid fa-microchip", - width: 800, - height: 650, - resizable: true - }, - content: content, - buttons: [ - { - action: "add", label: "Add New", icon: "fa-solid fa-plus", - callback: () => { this._onAdd(); return false; } - }, - { - action: "reset", label: "Reset", icon: "fa-solid fa-undo", - callback: () => { this._onReset(); return false; } - }, - { - action: "save", label: "Save & Close", icon: "fa-solid fa-save", - callback: (event, button) => this._onSave(event, button) - } - ], - render: (event, app) => { - const html = app.element; - - const form = html.querySelector('form'); - if (form) { - form.style.height = "100%"; - form.style.maxHeight = "100%"; - form.style.display = "flex"; - form.style.flexDirection = "column"; - form.style.overflow = "hidden"; - } - const formContent = html.querySelector('.form-content'); - if (formContent) { - formContent.style.flex = "1"; - formContent.style.overflow = "hidden"; - formContent.style.display = "flex"; - formContent.style.flexDirection = "column"; - } - - html.querySelectorAll('[data-action="delete"]').forEach(el => { - el.addEventListener('click', () => this._onDelete(el.dataset.id, app)); - }); - - html.addEventListener('drop', async (e) => { - // V14 namespaced TextEditor - const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(e); - if (data.type !== "Item") return; - - const targetRow = e.target.closest('[data-id]'); - const targetBonded = e.target.closest('.bonded-drop-zone'); - - if (targetBonded) { - await game.settings.set('dh-ikonis', 'defaultBondedUuid', data.uuid); - app.close(); this.open(); - return; - } - - if (targetRow) { - const id = targetRow.dataset.id; - const augs = game.settings.get('dh-ikonis', 'augmentsList') || [...DEFAULT_AUGMENTS]; - const idx = augs.findIndex(a => String(a.id) === String(id)); - if (idx !== -1) { - augs[idx].featureUuid = data.uuid; - await game.settings.set('dh-ikonis', 'augmentsList', augs); - } - app.close(); this.open(); - } - }); - - html.querySelectorAll('[data-action="clearFeature"]').forEach(el => { - el.addEventListener('click', async (e) => { - const id = el.dataset.id; - const augs = game.settings.get('dh-ikonis', 'augmentsList') || [...DEFAULT_AUGMENTS]; - const idx = augs.findIndex(a => String(a.id) === String(id)); - if (idx !== -1) { - augs[idx].featureUuid = null; - await game.settings.set('dh-ikonis', 'augmentsList', augs); - } - app.close(); this.open(); - }); - }); - } - }); - } - - static async _onAdd() { - const augments = game.settings.get('dh-ikonis', 'augmentsList') || [...DEFAULT_AUGMENTS]; - augments.push({ id: foundry.utils.randomID(), name: "New Augment", effect: "Effect", cost: "Cost", precompile: 1 }); - await game.settings.set('dh-ikonis', 'augmentsList', augments); - this.open(); - } - - static async _onDelete(id, app) { - const augments = (game.settings.get('dh-ikonis', 'augmentsList') || []).filter(a => String(a.id) !== String(id)); - await game.settings.set('dh-ikonis', 'augmentsList', augments); - app.close(); this.open(); - } - - static async _onReset() { - const confirmed = await foundry.applications.api.DialogV2.confirm({ - window: { title: "Reset" }, content: "Reset to defaults?", yes: { label: "Reset" } - }); - if (confirmed) { - await game.settings.set('dh-ikonis', 'augmentsList', DEFAULT_AUGMENTS); - await game.settings.set('dh-ikonis', 'defaultBondedUuid', ""); - this.open(); - } - } - - static async _onSave(event, button) { - // V14 namespaced FormDataExtended - const fde = new foundry.applications.ux.FormDataExtended(button.form); - const data = foundry.utils.expandObject(fde.object); - const currentAugs = game.settings.get('dh-ikonis', 'augmentsList') || []; - - const augments = Object.entries(data.augments || {}).map(([id, val]) => { - const existing = currentAugs.find(a => String(a.id) === String(id)); - return { - id, - name: val.name, - effect: val.effect, - cost: val.cost, - precompile: parseInt(val.precompile) || 1, - featureUuid: existing?.featureUuid || null - }; - }); - - await game.settings.set('dh-ikonis', 'augmentsList', augments); - ui.notifications.info("Global Hardware saved!"); - } -} diff --git a/scripts/ikonis-data.js b/scripts/ikonis-data.js index 37e6d3e..cf7f7be 100644 --- a/scripts/ikonis-data.js +++ b/scripts/ikonis-data.js @@ -1,15 +1,3 @@ -export const DEFAULT_AUGMENTS = [ - { id: "force", name: "Kinetic Amplifier", effect: "+1 Damage on Melee attacks", cost: "2 Iron", precompile: 1 }, - { id: "fire", name: "Thermal Core", effect: "Deals Fire damage instead of Physical", cost: "1 Blaze Glass", precompile: 1 }, - { id: "shock", name: "Static Coil", effect: "Targets hit are Dazed", cost: "3 Copper", precompile: 2 }, - { id: "shield", name: "Reactive Plating", effect: "+1 Armor while equipped", cost: "2 Steel", precompile: 1 }, - { id: "range", name: "Long-Range Optics", effect: "Increases Range by 1 step", cost: "1 Lens", precompile: 2 }, - { id: "crit", name: "Precision Chip", effect: "+1 to Crit range", cost: "1 Gold", precompile: 3 }, - { id: "multi", name: "Burst Module", effect: "Can target 2 enemies (Half damage)", cost: "2 Gears", precompile: 4 }, - { id: "drain", name: "Siphon Link", effect: "Recover 1 Hope on kill", cost: "1 Soul Gem", precompile: 4 }, - { id: "weight", name: "Gravity Plate", effect: "Weapon is Heavy (more damage)", cost: "4 Lead", precompile: 2 } -]; - // Global caches for resolved features to keep getters fast const _featureCache = new Map(); @@ -29,9 +17,9 @@ export function getAugments() { // Replace common line-breaking tags with actual newlines before stripping desc = desc.replace(/<\/p>|/gi, '\n'); desc = desc.replace(/<[^>]*>?/gm, '').trim(); - + const lines = desc.split('\n').map(l => l.trim()).filter(l => l.length > 0); - + const costLine = lines.find(l => l.toLowerCase().startsWith("cost:")); const effectLine = lines.find(l => !l.toLowerCase().startsWith("cost:")); @@ -56,7 +44,7 @@ export function getSlotCount(item) { let tier = item.system?.tier?.value; if (tier === undefined) tier = item.system?.tier; const tierNum = parseInt(tier) || 1; - + const settingKey = `slotsTier${tierNum}`; try { return game.settings.get('dh-ikonis', settingKey); diff --git a/templates/ikonis-config.hbs b/templates/ikonis-config.hbs deleted file mode 100644 index dcc8108..0000000 --- a/templates/ikonis-config.hbs +++ /dev/null @@ -1,40 +0,0 @@ - -
- -

Augment Blueprints

- -
- - - - - - - - - - - - {{#each augments as |aug|}} - - - - - - - - {{/each}} - -
NameEffectCostT
- - - - - - - - - -
-
-