Improved armor source names (#1851)

This commit is contained in:
WBHarry 2026-05-01 22:53:20 +02:00 committed by GitHub
parent 905d1f7e88
commit d0c2c783f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 9 deletions

View file

@ -22,9 +22,10 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
); );
const orderedArmorSources = getArmorSources(actor).filter(s => !s.disabled); const orderedArmorSources = getArmorSources(actor).filter(s => !s.disabled);
const armor = orderedArmorSources.reduce((acc, { document }) => { const armor = orderedArmorSources.reduce((acc, { name, document }) => {
const { current, max } = document.type === 'armor' ? document.system.armor : document.system.armorData; const { current, max } = document.type === 'armor' ? document.system.armor : document.system.armorData;
acc.push({ acc.push({
name,
effect: document, effect: document,
marks: [...Array(max).keys()].reduce((acc, _, index) => { marks: [...Array(max).keys()].reduce((acc, _, index) => {
const spent = index < current; const spent = index < current;
@ -152,14 +153,8 @@ export default class DamageReductionDialog extends HandlebarsApplicationMixin(Ap
const armorSources = []; const armorSources = [];
for (const source of this.marks.armor) { for (const source of this.marks.armor) {
const parent = source.effect.origin
? await foundry.utils.fromUuid(source.effect.origin)
: source.effect.parent;
const useEffectName = parent.type === 'armor' || parent instanceof Actor;
const label = useEffectName ? source.effect.name : parent.name;
armorSources.push({ armorSources.push({
label: label, label: source.name,
uuid: source.effect.uuid, uuid: source.effect.uuid,
marks: source.marks marks: source.marks
}); });

View file

@ -757,9 +757,12 @@ export function getArmorSources(actor) {
// Get the origin item. Since the actor is already loaded, it should already be cached // Get the origin item. Since the actor is already loaded, it should already be cached
// Consider the relative function versions if this causes an issue // Consider the relative function versions if this causes an issue
const origin = doc.origin ? foundry.utils.fromUuidSync(doc.origin) : doc; const origin = doc.origin ? foundry.utils.fromUuidSync(doc.origin) : doc;
const useParentName = doc.parent && !(doc.parent instanceof Actor);
const name = doc.origin || !useParentName ? doc.name : doc.parent.name;
return { return {
origin, origin,
name: origin.name, name,
document: doc, document: doc,
data: doc.system.armor ?? doc.system.armorData, data: doc.system.armor ?? doc.system.armorData,
disabled: !!doc.disabled || !!doc.isSuppressed disabled: !!doc.disabled || !!doc.isSuppressed