mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-08 06:56:12 +01:00
modify weapon data to split formula.
This commit is contained in:
parent
b9be9b9667
commit
4d64a99bb9
6 changed files with 26 additions and 50 deletions
|
|
@ -621,43 +621,15 @@ export class DHAttackAction extends DHDamageAction {
|
|||
super.prepareData();
|
||||
if (this.damage.includeBase && !!this.item?.system?.damage) {
|
||||
const baseDamage = this.getParentDamage();
|
||||
this.cleanBaseDamage(baseDamage);
|
||||
this.damage.parts.unshift(new DHDamageData(baseDamage));
|
||||
}
|
||||
}
|
||||
|
||||
cleanBaseDamage(baseDamage) {
|
||||
let possibleRoll = new Roll(baseDamage.value.dice);
|
||||
let die = 'd6';
|
||||
let modifier = 0;
|
||||
let nextOperator = '+';
|
||||
|
||||
possibleRoll.terms.forEach(term => {
|
||||
if (term instanceof DiceTerm) {
|
||||
die = `d${term._faces}`;
|
||||
}
|
||||
if (term instanceof OperatorTerm) {
|
||||
nextOperator = term.operator;
|
||||
}
|
||||
if (term instanceof NumericTerm) {
|
||||
if (nextOperator == '+') {
|
||||
modifier += term.number;
|
||||
}
|
||||
|
||||
if (nextOperator == '-') {
|
||||
modifier -= term.number;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return (baseDamage.value = { ...baseDamage.value, dice: die, bonus: modifier });
|
||||
}
|
||||
|
||||
getParentDamage() {
|
||||
return {
|
||||
value: {
|
||||
multiplier: 'prof',
|
||||
dice: this.item?.system?.damage.value,
|
||||
dice: this.item?.system?.damage.dice,
|
||||
bonus: this.item?.system?.damage.bonus ?? 0
|
||||
},
|
||||
type: this.item?.system?.damage.type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue