mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] Encounter Battlepoints (#1346)
* Added BP calculation and tooltip breakdown of BP sources * Added Modifiers * Fixed automatic battleToggles * Corrected 'NoToughies' conditional * Fixed GM-only visibility * Fixed combatant isNPC
This commit is contained in:
parent
c3cb9121af
commit
451bef4c92
21 changed files with 712 additions and 141 deletions
|
|
@ -1,6 +1,39 @@
|
|||
export default class DhCombat extends foundry.abstract.TypeDataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {};
|
||||
return {
|
||||
battleToggles: new fields.ArrayField(
|
||||
new fields.SchemaField({
|
||||
category: new fields.NumberField({ required: true, integer: true }),
|
||||
grouping: new fields.StringField({ required: true })
|
||||
})
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
/** Includes automatic BPModifiers */
|
||||
get extendedBattleToggles() {
|
||||
const modifiers = CONFIG.DH.ENCOUNTER.BPModifiers;
|
||||
const adversaries =
|
||||
this.parent.turns?.filter(x => x.isNPC)?.map(x => ({ ...x.actor, type: x.actor.system.type })) ?? [];
|
||||
const characters = this.parent.turns?.filter(x => !x.isNPC) ?? [];
|
||||
|
||||
const activeAutomatic = Object.keys(modifiers).reduce((acc, categoryKey) => {
|
||||
const category = modifiers[categoryKey];
|
||||
acc.push(
|
||||
...Object.keys(category).reduce((acc, groupingKey) => {
|
||||
const grouping = category[groupingKey];
|
||||
if (grouping.automatic && grouping.conditional?.(this.parent, adversaries, characters)) {
|
||||
acc.push({ category: Number(categoryKey), grouping: groupingKey });
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, [])
|
||||
);
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
|
||||
return [...this.battleToggles, ...activeAutomatic];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue