refactor: remove legacy augmentation configuration template and script files

This commit is contained in:
CPTN Cosmo 2026-04-26 19:20:51 +02:00
parent a6a467e353
commit 6cfadbc1ac
3 changed files with 3 additions and 215 deletions

View file

@ -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!");
}
}

View file

@ -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>|<br\s*\/?>/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);

View file

@ -1,40 +0,0 @@
<div class="ikonis-config-container" style="background: #0d0d16; color: white; padding: 1.5rem; display: flex; flex-direction: column; max-height: 600px; box-sizing: border-box;">
<h3 style="flex: 0 0 auto; margin: 0 0 0.5rem 0; color: #ff2e63; font-size: 1.1rem;">Augment Blueprints</h3>
<div class="augment-manager-scroll" style="flex: 1; overflow-y: auto; border: 1px solid #2d3436; border-radius: 8px; background: rgba(0,0,0,0.2); margin-bottom: 0.5rem; min-height: 150px;">
<table class="config-table" style="width: 100%; border-collapse: separate; border-spacing: 0;">
<thead style="position: sticky; top: 0; background: #16213e; z-index: 10;">
<tr style="text-align: left;">
<th style="padding: 0.75rem 0.5rem; color: #ff2e63; border-bottom: 2px solid #ff2e63;">Name</th>
<th style="padding: 0.75rem 0.5rem; color: #ff2e63; border-bottom: 2px solid #ff2e63;">Effect</th>
<th style="padding: 0.75rem 0.5rem; color: #ff2e63; border-bottom: 2px solid #ff2e63;">Cost</th>
<th style="padding: 0.75rem 0.5rem; width: 50px; color: #ff2e63; border-bottom: 2px solid #ff2e63;">T</th>
<th style="padding: 0.75rem 0.5rem; width: 30px; border-bottom: 2px solid #ff2e63;"></th>
</tr>
</thead>
<tbody>
{{#each augments as |aug|}}
<tr style="border-bottom: 1px solid #2d3436;" data-id="{{aug.id}}">
<td style="padding: 0.4rem;">
<input type="text" name="augments.{{aug.id}}.name" value="{{aug.name}}" style="width: 100%; background: #1a1a2e; color: white; border: 1px solid #333; padding: 2px 4px;">
</td>
<td style="padding: 0.4rem;">
<input type="text" name="augments.{{aug.id}}.effect" value="{{aug.effect}}" style="width: 100%; background: #1a1a2e; color: white; border: 1px solid #333; padding: 2px 4px;">
</td>
<td style="padding: 0.4rem;">
<input type="text" name="augments.{{aug.id}}.cost" value="{{aug.cost}}" style="width: 100%; background: #1a1a2e; color: white; border: 1px solid #333; padding: 2px 4px;">
</td>
<td style="padding: 0.4rem;">
<input type="number" name="augments.{{aug.id}}.precompile" value="{{aug.precompile}}" min="1" max="4" style="width: 100%; background: #1a1a2e; color: white; border: 1px solid #333; padding: 2px 4px;">
</td>
<td style="padding: 0.4rem; text-align: center;">
<a data-action="delete" data-id="{{aug.id}}" style="color: #ff2e63;"><i class="fa-solid fa-trash"></i></a>
</td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>