[Feature] 789 - spotlight order (#1222)

* order spotlight requests

* add spotlight requests section to combat tracker
This commit is contained in:
IrkTheImp 2025-10-25 11:59:25 -05:00 committed by GitHub
parent 45b9b52314
commit d4f80b6fa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 4 deletions

View file

@ -1884,6 +1884,10 @@
}
}
},
"SpotlightRequests": {
"singular": "Spotlight Request",
"plural": "Spotlight Requests"
},
"Tabs": {
"details": "Details",
"attack": "Attack",

View file

@ -36,10 +36,21 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
const adversaries = context.turns?.filter(x => x.isNPC) ?? [];
const characters = context.turns?.filter(x => !x.isNPC) ?? [];
const spotlightRequests = characters
?.filter(x => !x.isNPC)
.filter(x => x.system.spotlight.requestOrderIndex > 0)
.sort((a, b) => {
const valueA = a.system.spotlight.requestOrderIndex;
const valueB = b.system.spotlight.requestOrderIndex;
return valueA - valueB;
});
Object.assign(context, {
actionTokens: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).actionTokens,
adversaries,
characters
characters: characters?.filter(x => !x.isNPC).filter(x => x.system.spotlight.requestOrderIndex == 0),
spotlightRequests
});
}
@ -114,7 +125,8 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
async setCombatantSpotlight(combatantId) {
const update = {
system: {
'spotlight.requesting': false
'spotlight.requesting': false,
'spotlight.requestOrderIndex': 0
}
};
const combatant = this.viewed.combatants.get(combatantId);
@ -142,11 +154,15 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
}
static async requestSpotlight(_, target) {
const characters = this.viewed.turns?.filter(x => !x.isNPC) ?? [];
const orderValues = characters.map(character => character.system.spotlight.requestOrderIndex);
const maxRequestIndex = Math.max(...orderValues);
const { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
const combatant = this.viewed.combatants.get(combatantId);
await combatant.update({
'system.spotlight': {
requesting: !combatant.system.spotlight.requesting
requesting: !combatant.system.spotlight.requesting,
requestOrderIndex: !combatant.system.spotlight.requesting ? maxRequestIndex + 1 : 0
}
});

View file

@ -3,7 +3,8 @@ export default class DhCombatant extends foundry.abstract.TypeDataModel {
const fields = foundry.data.fields;
return {
spotlight: new fields.SchemaField({
requesting: new fields.BooleanField({ required: true, initial: false })
requesting: new fields.BooleanField({ required: true, initial: false }),
requestOrderIndex: new fields.NumberField({ required: true, integer: true, initial: 0 })
}),
actionTokens: new fields.NumberField({ required: true, integer: true, initial: 3 })
};

View file

@ -1,4 +1,7 @@
<div class="combat-tracker">
{{#if (gt this.spotlightRequests.length 0)}}
{{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.SpotlightRequests.plural") turns=this.spotlightRequests}}
{{/if}}
{{#if (gt this.characters.length 0)}}
{{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Character.plural") turns=this.characters}}
{{/if}}