From 3f9f4fac1744bbe3a3c24b38941c8069bc046a08 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Sun, 10 May 2026 14:47:41 +0200 Subject: [PATCH] Introduced a adversary category split for BP calculation and CombatTracker display based on token disposition --- lang/en.json | 6 +++++- module/applications/ui/combatTracker.mjs | 12 ++++++++++-- module/documents/tooltipManager.mjs | 4 +++- templates/ui/combatTracker/combatTracker.hbs | 6 ++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lang/en.json b/lang/en.json index 20c66a32..19fddaf3 100755 --- a/lang/en.json +++ b/lang/en.json @@ -406,7 +406,11 @@ "giveSpotlight": "Give The Spotlight", "requestingSpotlight": "Requesting The Spotlight", "requestSpotlight": "Request The Spotlight", - "openCountdowns": "Countdowns" + "openCountdowns": "Countdowns", + "adversaryCategories": { + "friendly": "Friendly", + "neutral": "Neutral" + } }, "CompendiumBrowserSettings": { "title": "Enable Compendiums", diff --git a/module/applications/ui/combatTracker.mjs b/module/applications/ui/combatTracker.mjs index fb19a17e..3189b10e 100644 --- a/module/applications/ui/combatTracker.mjs +++ b/module/applications/ui/combatTracker.mjs @@ -56,7 +56,12 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C async _prepareTrackerContext(context, options) { await super._prepareTrackerContext(context, options); - const adversaries = context.turns?.filter(x => x.isNPC) ?? []; + const npcs = context.turns?.filter(x => x.isNPC) ?? []; + const adversaries = npcs.filter(x => x.disposition === CONST.TOKEN_DISPOSITIONS.HOSTILE); + const friendlies = npcs.filter(x => x.disposition === CONST.TOKEN_DISPOSITIONS.FRIENDLY); + const neutrals = npcs.filter(x => + [CONST.TOKEN_DISPOSITIONS.SECRET, CONST.TOKEN_DISPOSITIONS.NEUTRAL].includes(x.disposition) + ); const characters = context.turns?.filter(x => !x.isNPC) ?? []; const spotlightQueueEnabled = game.settings.get( CONFIG.DH.id, @@ -75,6 +80,8 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C Object.assign(context, { actionTokens: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).actionTokens, adversaries, + friendlies, + neutrals, allCharacters: characters, characters: characters.filter(x => !spotlightQueueEnabled || x.system.spotlight.requestOrderIndex == 0), spotlightRequests @@ -129,7 +136,8 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C active: index === combat.turn, canPing: combatant.sceneId === canvas.scene?.id && game.user.hasPermission('PING_CANVAS'), type: combatant.actor?.system?.type, - img: await this._getCombatantThumbnail(combatant) + img: await this._getCombatantThumbnail(combatant), + disposition: combatant.token.disposition }; turn.css = [turn.active ? 'active' : null, hidden ? 'hide' : null, isDefeated ? 'defeated' : null].filterJoin( diff --git a/module/documents/tooltipManager.mjs b/module/documents/tooltipManager.mjs index e10dc5fa..18c03169 100644 --- a/module/documents/tooltipManager.mjs +++ b/module/documents/tooltipManager.mjs @@ -350,7 +350,9 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti async getBattlepointHTML(combatId) { const combat = game.combats.get(combatId); const adversaries = - combat.turns?.filter(x => x.actor?.isNPC)?.map(x => ({ ...x.actor, type: x.actor.system.type })) ?? []; + combat.turns + ?.filter(x => x.actor?.isNPC && x.token.disposition === CONST.TOKEN_DISPOSITIONS.HOSTILE) + ?.map(x => ({ ...x.actor, type: x.actor.system.type })) ?? []; const characters = combat.turns?.filter(x => !x.isNPC && x.actor) ?? []; const nrCharacters = characters.length; diff --git a/templates/ui/combatTracker/combatTracker.hbs b/templates/ui/combatTracker/combatTracker.hbs index 91f7786b..5fb27c7f 100644 --- a/templates/ui/combatTracker/combatTracker.hbs +++ b/templates/ui/combatTracker/combatTracker.hbs @@ -5,6 +5,12 @@ {{#if (gt this.characters.length 0)}} {{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Character.plural") turns=this.characters}} {{/if}} + {{#if (gt this.friendlies.length 0)}} + {{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.APPLICATIONS.CombatTracker.adversaryCategories.friendly") turns=this.friendlies}} + {{/if}} + {{#if (gt this.neutrals.length 0)}} + {{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.APPLICATIONS.CombatTracker.adversaryCategories.neutral") turns=this.neutrals}} + {{/if}} {{#if (gt this.adversaries.length 0)}} {{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Adversary.plural") turns=this.adversaries}} {{/if}}