feat: add Bonded feature display to motherboard sheet with auto-installation logic

This commit is contained in:
CPTN Cosmo 2026-04-26 19:06:32 +02:00
parent a421950b3e
commit 328932d6b0
2 changed files with 40 additions and 1 deletions

View file

@ -46,8 +46,35 @@ export function patchIkonisSheet() {
const allAugmentsList = getAugments() || [];
const processedAugments = [];
let bondedFeature = null;
// Search for "Ikonis: Bonded" globally
const allNativeFeatures = CONFIG.DH.ITEM.allWeaponFeatures() || {};
const bondedId = Object.keys(allNativeFeatures).find(k => allNativeFeatures[k].name === "Ikonis: Bonded");
// Auto-install if missing
if (bondedId && !weaponFeatures.some(f => f.value === bondedId)) {
console.log(`DH-Ikonis | Auto-installing Bonded feature on ${doc.name}`);
const newFeatures = [...weaponFeatures, { value: bondedId }];
doc.update({ "system.weaponFeatures": newFeatures });
}
for (const featureRef of weaponFeatures) {
const nativeId = featureRef.value;
// Special handling for Bonded
if (nativeId === bondedId) {
const feature = allNativeFeatures[bondedId];
bondedFeature = {
id: bondedId,
name: "Bonded",
fullName: feature.name,
effect: feature.description ? feature.description.replace(/<[^>]*>?/gm, '').substring(0, 100) + "..." : "Primary module",
installed: true
};
continue;
}
const base = allAugmentsList.find(a => String(a.id) === String(nativeId));
if (!base) continue;
@ -57,11 +84,12 @@ export function patchIkonisSheet() {
context.ikonis = {
enabled: true,
augments: processedAugments,
bonded: bondedFeature,
isGM: game.user?.isGM || false
};
context.maxSlots = getSlotCount(doc);
context.usedSlots = processedAugments.length;
context.usedSlots = processedAugments.length; // Bonded doesn't count
// Explicitly pass the active tab to the template
context.activeTab = this.tabGroups?.primary || "";