From c3e4f3922ed7fbee7c6bc3c7f118a44ec30a20d2 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 28 Jul 2025 04:36:32 +0200 Subject: [PATCH] Redid it a better way --- module/applications/hud/tokenHUD.mjs | 3 --- module/canvas/placeables/token.mjs | 24 ++++++++++++++++++++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/module/applications/hud/tokenHUD.mjs b/module/applications/hud/tokenHUD.mjs index 572b03f9..5c29260b 100644 --- a/module/applications/hud/tokenHUD.mjs +++ b/module/applications/hud/tokenHUD.mjs @@ -66,12 +66,9 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD { if (!status) continue; if (status._id) { if (status._id !== effect.id) continue; - } else { - if (effect.statuses.size !== 1) continue; } status.isActive = true; if (effect.getFlag('core', 'overlay')) status.isOverlay = true; - break; } } diff --git a/module/canvas/placeables/token.mjs b/module/canvas/placeables/token.mjs index 967df0f8..dd6f089e 100644 --- a/module/canvas/placeables/token.mjs +++ b/module/canvas/placeables/token.mjs @@ -10,8 +10,28 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token { this.effects.overlay = null; // Categorize effects - const activeEffects = this.actor ? Array.from(this.actor.effects).filter(x => !x.disabled) : []; - const overlayEffect = activeEffects.findLast(e => e.img && e.getFlag('core', 'overlay')); + const statusMap = new Map(foundry.CONFIG.statusEffects.map(status => [status.id, status])); + const activeEffects = (this.actor ? this.actor.effects.filter(x => !x.disabled) : []).reduce((acc, effect) => { + acc.push(effect); + + const currentStatusActiveEffects = acc.filter( + x => x.statuses.size === 1 && x.name === game.i18n.localize(statusMap.get(x.statuses.first()).name) + ); + for (var status of effect.statuses) { + if (!currentStatusActiveEffects.find(x => x.statuses.includes(status))) { + const statusData = statusMap.get(status); + acc.push({ + name: game.i18n.localize(statusData.name), + statuses: [status], + img: statusData.icon, + tint: effect.tint + }); + } + } + + return acc; + }, []); + const overlayEffect = activeEffects.findLast(e => e.img && e.getFlag?.('core', 'overlay')); // Draw effects const promises = [];