mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 22:46:12 +01:00
fix weapon action damage and display of calculation.
This commit is contained in:
parent
9fb9a4af55
commit
bf08691bbf
7 changed files with 46 additions and 14 deletions
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue