mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
order spotlight requests
This commit is contained in:
parent
45b9b52314
commit
66218ff943
2 changed files with 21 additions and 4 deletions
|
|
@ -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 sortedCharacters = 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;
|
||||
})
|
||||
.concat(characters?.filter(x => !x.isNPC).filter(x => x.system.spotlight.requestOrderIndex == 0));
|
||||
|
||||
Object.assign(context, {
|
||||
actionTokens: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).actionTokens,
|
||||
adversaries,
|
||||
characters
|
||||
characters: sortedCharacters
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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 })
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue