feat: add Bonded feature display to motherboard sheet with auto-installation logic
This commit is contained in:
parent
a421950b3e
commit
328932d6b0
2 changed files with 40 additions and 1 deletions
|
|
@ -46,8 +46,35 @@ export function patchIkonisSheet() {
|
||||||
const allAugmentsList = getAugments() || [];
|
const allAugmentsList = getAugments() || [];
|
||||||
|
|
||||||
const processedAugments = [];
|
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) {
|
for (const featureRef of weaponFeatures) {
|
||||||
const nativeId = featureRef.value;
|
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));
|
const base = allAugmentsList.find(a => String(a.id) === String(nativeId));
|
||||||
if (!base) continue;
|
if (!base) continue;
|
||||||
|
|
||||||
|
|
@ -57,11 +84,12 @@ export function patchIkonisSheet() {
|
||||||
context.ikonis = {
|
context.ikonis = {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
augments: processedAugments,
|
augments: processedAugments,
|
||||||
|
bonded: bondedFeature,
|
||||||
isGM: game.user?.isGM || false
|
isGM: game.user?.isGM || false
|
||||||
};
|
};
|
||||||
|
|
||||||
context.maxSlots = getSlotCount(doc);
|
context.maxSlots = getSlotCount(doc);
|
||||||
context.usedSlots = processedAugments.length;
|
context.usedSlots = processedAugments.length; // Bonded doesn't count
|
||||||
|
|
||||||
// Explicitly pass the active tab to the template
|
// Explicitly pass the active tab to the template
|
||||||
context.activeTab = this.tabGroups?.primary || "";
|
context.activeTab = this.tabGroups?.primary || "";
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,17 @@
|
||||||
</div>
|
</div>
|
||||||
</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="augments-section">
|
||||||
<div class="section-header" style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem;">
|
<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>
|
<h3 style="margin: 0; color: #e0e0e0;">Installed Augments</h3>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue