From 8fad165977b5b1bf90278633c747b1e96368b6e6 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 31 Jul 2025 19:14:54 +0200 Subject: [PATCH] Made suggested items inactive in the Class sheet if rendered from inside a Character --- module/applications/sheets/items/class.mjs | 76 +++++++++++----------- styles/less/global/elements.less | 4 ++ templates/sheets/items/class/settings.hbs | 26 ++++---- 3 files changed, 56 insertions(+), 50 deletions(-) diff --git a/module/applications/sheets/items/class.mjs b/module/applications/sheets/items/class.mjs index c78e1de1..3dce0a11 100644 --- a/module/applications/sheets/items/class.mjs +++ b/module/applications/sheets/items/class.mjs @@ -113,45 +113,47 @@ export default class ClassSheet extends DHBaseItemSheet { }); } else if (item.type === 'feature') { super._onDrop(event); - } else if (item.type === 'weapon') { - if (target.classList.contains('primary-weapon-section')) { - if (!item.system.secondary) + } else if (this.document.parent?.type !== 'character') { + if (item.type === 'weapon') { + if (target.classList.contains('primary-weapon-section')) { + if (!item.system.secondary) + await this.document.update({ + 'system.characterGuide.suggestedPrimaryWeapon': item.uuid + }); + } else if (target.classList.contains('secondary-weapon-section')) { + if (item.system.secondary) + await this.document.update({ + 'system.characterGuide.suggestedSecondaryWeapon': item.uuid + }); + } + } else if (item.type === 'armor') { + if (target.classList.contains('armor-section')) { await this.document.update({ - 'system.characterGuide.suggestedPrimaryWeapon': item.uuid - }); - } else if (target.classList.contains('secondary-weapon-section')) { - if (item.system.secondary) - await this.document.update({ - 'system.characterGuide.suggestedSecondaryWeapon': item.uuid - }); - } - } else if (item.type === 'armor') { - if (target.classList.contains('armor-section')) { - await this.document.update({ - 'system.characterGuide.suggestedArmor': item.uuid - }); - } - } else if (target.classList.contains('choice-a-section')) { - if (item.type === 'loot' || item.type === 'consumable') { - const filteredChoiceA = this.document.system.inventory.choiceA; - if (filteredChoiceA.length < 2) - await this.document.update({ - 'system.inventory.choiceA': [...filteredChoiceA.map(x => x.uuid), item.uuid] - }); - } - } else if (item.type === 'loot') { - if (target.classList.contains('take-section')) { - const filteredTake = this.document.system.inventory.take.filter(x => x); - if (filteredTake.length < 3) - await this.document.update({ - 'system.inventory.take': [...filteredTake.map(x => x.uuid), item.uuid] - }); - } else if (target.classList.contains('choice-b-section')) { - const filteredChoiceB = this.document.system.inventory.choiceB.filter(x => x); - if (filteredChoiceB.length < 2) - await this.document.update({ - 'system.inventory.choiceB': [...filteredChoiceB.map(x => x.uuid), item.uuid] + 'system.characterGuide.suggestedArmor': item.uuid }); + } + } else if (target.classList.contains('choice-a-section')) { + if (item.type === 'loot' || item.type === 'consumable') { + const filteredChoiceA = this.document.system.inventory.choiceA; + if (filteredChoiceA.length < 2) + await this.document.update({ + 'system.inventory.choiceA': [...filteredChoiceA.map(x => x.uuid), item.uuid] + }); + } + } else if (item.type === 'loot') { + if (target.classList.contains('take-section')) { + const filteredTake = this.document.system.inventory.take.filter(x => x); + if (filteredTake.length < 3) + await this.document.update({ + 'system.inventory.take': [...filteredTake.map(x => x.uuid), item.uuid] + }); + } else if (target.classList.contains('choice-b-section')) { + const filteredChoiceB = this.document.system.inventory.choiceB.filter(x => x); + if (filteredChoiceB.length < 2) + await this.document.update({ + 'system.inventory.choiceB': [...filteredChoiceB.map(x => x.uuid), item.uuid] + }); + } } } } diff --git a/styles/less/global/elements.less b/styles/less/global/elements.less index 8a3677ae..1bdc105e 100755 --- a/styles/less/global/elements.less +++ b/styles/less/global/elements.less @@ -206,6 +206,10 @@ } } + &.inactive { + opacity: 0.5; + } + &.fit-height { height: 95%; } diff --git a/templates/sheets/items/class/settings.hbs b/templates/sheets/items/class/settings.hbs index 662e7507..9ac2b14f 100644 --- a/templates/sheets/items/class/settings.hbs +++ b/templates/sheets/items/class/settings.hbs @@ -31,10 +31,10 @@ {{localize "DAGGERHEART.CONFIG.Traits.knowledge.name"}} - +
{{localize "DAGGERHEART.ITEMS.Class.guide.suggestedEquipment"}} -
+
{{localize "DAGGERHEART.ITEMS.Class.guide.suggestedPrimaryWeaponTitle"}}
{{#if document.system.characterGuide.suggestedPrimaryWeapon}} @@ -42,14 +42,14 @@ {{document.system.characterGuide.suggestedPrimaryWeapon.name}}
- + {{#unless (eq document.parent.type 'character')}}{{/unless}}
{{/if}}
-
+
{{localize "DAGGERHEART.ITEMS.Class.guide.suggestedSecondaryWeaponTitle"}}
{{#if document.system.characterGuide.suggestedSecondaryWeapon}} @@ -57,14 +57,14 @@ {{document.system.characterGuide.suggestedSecondaryWeapon.name}}
- + {{#unless (eq document.parent.type 'character')}}{{/unless}}
{{/if}}
-
+
{{localize "DAGGERHEART.ITEMS.Class.guide.suggestedArmorTitle"}}
{{#if document.system.characterGuide.suggestedArmor}} @@ -72,7 +72,7 @@ {{document.system.characterGuide.suggestedArmor.name}}
- + {{#unless (eq document.parent.type 'character')}}{{/unless}}
{{/if}} @@ -82,7 +82,7 @@
{{localize "DAGGERHEART.GENERAL.inventory"}} -
+
{{localize "DAGGERHEART.GENERAL.take"}}
{{#each source.system.inventory.take}} @@ -91,7 +91,7 @@ {{this.name}}
- + {{#unless (eq document.parent.type 'character')}}{{/unless}}
{{/if}} @@ -99,7 +99,7 @@
-
+
{{localize "DAGGERHEART.ITEMS.Class.guide.inventory.thenChoose"}}
{{#each source.system.inventory.choiceA}} @@ -108,7 +108,7 @@ {{this.name}}
- + {{#unless (eq document.parent.type 'character')}}{{/unless}}
{{/if}} @@ -116,7 +116,7 @@
-
+
{{localize "DAGGERHEART.ITEMS.Class.guide.inventory.andEither"}}
{{#each source.system.inventory.choiceB}} @@ -125,7 +125,7 @@ {{this.name}}
- + {{#unless (eq document.parent.type 'character')}}{{/unless}}
{{/if}}