mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Moved the damageFormula function to damageAction
This commit is contained in:
parent
51135b6a67
commit
e9752f5461
3 changed files with 14 additions and 17 deletions
|
|
@ -2,4 +2,17 @@ import DHBaseAction from './baseAction.mjs';
|
|||
|
||||
export default class DHDamageAction extends DHBaseAction {
|
||||
static extraSchemas = [...super.extraSchemas, 'damage', 'target', 'effects'];
|
||||
|
||||
/**
|
||||
* Return a display ready damage formula string
|
||||
* @returns Formula string
|
||||
*/
|
||||
getDamageFormula() {
|
||||
const strings = [];
|
||||
for (const { value } of this.damage.parts) {
|
||||
strings.push(Roll.replaceFormulaData(value.getFormula(), this.actor?.getRollData() ?? {}));
|
||||
}
|
||||
|
||||
return strings.join(' + ');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,22 +161,6 @@ export default class DamageField extends fields.SchemaField {
|
|||
return formulaValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a display ready damage formula string
|
||||
* Must be called within Action context or similar.
|
||||
* @param {Array<object>} parts Damage Parts
|
||||
* @param {object} data Action getRollData
|
||||
* @returns Formula string
|
||||
*/
|
||||
static getFormulaString(parts) {
|
||||
const strings = [];
|
||||
for (const { value } of parts) {
|
||||
strings.push(Roll.replaceFormulaData(value.getFormula(), this.actor?.getRollData() ?? {}));
|
||||
}
|
||||
|
||||
return strings.join(' + ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare formulas for Damage Roll
|
||||
* Must be called within Action context or similar.
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export default class RegisterHandlebarsHelpers {
|
|||
}
|
||||
|
||||
static damageFormula(attack) {
|
||||
return game.system.api.fields.ActionFields.DamageField.getFormulaString.bind(attack)(attack.damage.parts);
|
||||
return attack.getDamageFormula();
|
||||
}
|
||||
|
||||
static formulaValue(formula, item) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue