Fix damage & healing roll

This commit is contained in:
Dapoolp 2025-08-01 19:49:59 +02:00
parent 57f19c41cd
commit a25dbb462c
19 changed files with 200 additions and 60 deletions

View file

@ -19,7 +19,7 @@ export default class DHDamageRoll extends foundry.abstract.TypeDataModel {
})
})
),
targetSelection: new fields.BooleanField({ initial: true }),
targetSelection: new fields.BooleanField({ initial: false }),
hasSave: new fields.BooleanField({ initial: false }),
isHealing: new fields.BooleanField({ initial: false }),
onSave: new fields.StringField(),
@ -29,7 +29,12 @@ export default class DHDamageRoll extends foundry.abstract.TypeDataModel {
action: new fields.StringField(),
message: new fields.StringField()
}),
directDamage: new fields.BooleanField({ initial: true })
directDamage: new fields.BooleanField({ initial: true }),
damage: new fields.ObjectField(),
hasRoll: new fields.BooleanField({ initial: false }),
hasDamage: new fields.BooleanField({ initial: false }),
hasHealing: new fields.BooleanField({ initial: false }),
hasEffect: new fields.BooleanField({ initial: false })
};
}
@ -46,5 +51,15 @@ export default class DHDamageRoll extends foundry.abstract.TypeDataModel {
game.system.api.fields.ActionFields.TargetField.formatTarget(t)
)
: this.targets;
if(this.targetSelection === true) {
this.targetShort = this.targets.reduce((a,c) => {
if(c.hit) a.hit += 1;
else c.miss += 1;
return a;
}, {hit: 0, miss: 0})
}
this.pendingSaves = this.targets.filter(
target => target.hit && target.saved.success === null
).length > 0;
}
}