mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] 789 - spotlight order (#1222)
* order spotlight requests * add spotlight requests section to combat tracker
This commit is contained in:
parent
45b9b52314
commit
d4f80b6fa1
4 changed files with 28 additions and 4 deletions
|
|
@ -1884,6 +1884,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"SpotlightRequests": {
|
||||||
|
"singular": "Spotlight Request",
|
||||||
|
"plural": "Spotlight Requests"
|
||||||
|
},
|
||||||
"Tabs": {
|
"Tabs": {
|
||||||
"details": "Details",
|
"details": "Details",
|
||||||
"attack": "Attack",
|
"attack": "Attack",
|
||||||
|
|
|
||||||
|
|
@ -36,10 +36,21 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C
|
||||||
const adversaries = context.turns?.filter(x => x.isNPC) ?? [];
|
const adversaries = context.turns?.filter(x => x.isNPC) ?? [];
|
||||||
const characters = 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, {
|
Object.assign(context, {
|
||||||
actionTokens: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).actionTokens,
|
actionTokens: game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.variantRules).actionTokens,
|
||||||
adversaries,
|
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) {
|
async setCombatantSpotlight(combatantId) {
|
||||||
const update = {
|
const update = {
|
||||||
system: {
|
system: {
|
||||||
'spotlight.requesting': false
|
'spotlight.requesting': false,
|
||||||
|
'spotlight.requestOrderIndex': 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const combatant = this.viewed.combatants.get(combatantId);
|
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) {
|
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 { combatantId } = target.closest('[data-combatant-id]')?.dataset ?? {};
|
||||||
const combatant = this.viewed.combatants.get(combatantId);
|
const combatant = this.viewed.combatants.get(combatantId);
|
||||||
await combatant.update({
|
await combatant.update({
|
||||||
'system.spotlight': {
|
'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;
|
const fields = foundry.data.fields;
|
||||||
return {
|
return {
|
||||||
spotlight: new fields.SchemaField({
|
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 })
|
actionTokens: new fields.NumberField({ required: true, integer: true, initial: 3 })
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
<div class="combat-tracker">
|
<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)}}
|
{{#if (gt this.characters.length 0)}}
|
||||||
{{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Character.plural") turns=this.characters}}
|
{{> 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs' this title=(localize "DAGGERHEART.GENERAL.Character.plural") turns=this.characters}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue