fix weapon action damage and display of calculation.

This commit is contained in:
IrkTheImp 2025-07-02 22:12:34 -05:00
parent 9fb9a4af55
commit bf08691bbf
7 changed files with 46 additions and 14 deletions

View file

@ -231,6 +231,7 @@ export class DHBaseAction extends foundry.abstract.DataModel {
}
if (this.hasRoll) {
console.log(config);
const rollConfig = this.prepareRoll(config);
config.roll = rollConfig;
config = await this.actor.diceRoll(config);
@ -242,7 +243,6 @@ export class DHBaseAction extends foundry.abstract.DataModel {
if(t.hit) {
const target = game.canvas.tokens.get(t.id),
actor = target?.actor;
console.log(actor)
if(!actor) return;
actor.saveRoll({
event,
@ -621,10 +621,38 @@ 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: {