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

View file

@ -7,6 +7,17 @@
</div>
</div>
{{#if ikonis.bonded}}
<div class="bonded-feature motherboard-card" style="border-left: 4px solid #ff2e63; background: rgba(255,46,99,0.05); margin-bottom: 2rem; padding: 1rem; border-radius: 8px;">
<div class="bonded-info" style="display: flex; align-items: center; gap: 1rem;">
<div class="text">
<h3 style="margin: 0; color: #ff2e63; font-size: 1.2rem;">{{ikonis.bonded.fullName}} (Primary)</h3>
<p style="margin: 0.25rem 0 0 0; color: #d1d8e0; font-size: 0.95rem;">{{ikonis.bonded.effect}}</p>
</div>
</div>
</div>
{{/if}}
<div class="augments-section">
<div class="section-header" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;">
<h3 style="margin: 0; color: #e0e0e0;">Installed Augments</h3>