[Feature] 1766 - Group Attack (#1770)

* Implemented group attack logic

* Updated all minions in the SRD to use the group attack functionality

* .

* Renamed groupAttack.nr to groupAttack.numAttackers

* Moved the flag vs global setting logic to documents/scene

* .
This commit is contained in:
WBHarry 2026-04-09 22:07:51 +02:00 committed by GitHub
parent b505e15eb2
commit ae480157d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
32 changed files with 1286 additions and 220 deletions

View file

@ -144,6 +144,7 @@ export default class DamageRoll extends DHRoll {
constructFormula(config) {
this.options.isCritical = config.isCritical;
for (const [index, part] of this.options.roll.entries()) {
const isHitpointPart = part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id;
part.roll = new Roll(Roll.replaceFormulaData(part.formula, config.data));
part.roll.terms = Roll.parse(part.roll.formula, config.data);
if (part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
@ -169,7 +170,16 @@ export default class DamageRoll extends DHRoll {
);
}
if (config.isCritical && part.applyTo === CONFIG.DH.GENERAL.healingTypes.hitPoints.id) {
if (config.damageOptions.groupAttack?.numAttackers > 1 && isHitpointPart) {
const damageTypes = [foundry.dice.terms.Die, foundry.dice.terms.NumericTerm];
for (const term of part.roll.terms) {
if (damageTypes.some(type => term instanceof type)) {
term.number *= config.damageOptions.groupAttack.numAttackers;
}
}
}
if (config.isCritical && isHitpointPart) {
const total = part.roll.dice.reduce((acc, term) => acc + term._faces * term._number, 0);
if (total > 0) {
part.roll.terms.push(...this.formatModifier(total));