This commit is contained in:
Dapoolp 2025-07-31 13:33:39 +02:00
parent dbb07008f0
commit faa32c1fba
10 changed files with 90 additions and 59 deletions

View file

@ -165,6 +165,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
},
dialog: {},
type: this.type,
hasRoll: this.hasRoll,
hasDamage: this.damage?.parts?.length && this.type !== 'healing',
hasHealing: this.damage?.parts?.length && this.type === 'healing',
hasEffect: !!this.effects?.length,

View file

@ -20,7 +20,7 @@ export default class DHAdversaryRoll extends foundry.abstract.TypeDataModel {
})
})
),
targetSelection: new fields.BooleanField({ initial: true }),
targetSelection: new fields.BooleanField({ initial: false }),
hasRoll: new fields.BooleanField({ initial: false }),
hasDamage: new fields.BooleanField({ initial: false }),
hasHealing: new fields.BooleanField({ initial: false }),
@ -47,5 +47,12 @@ export default class DHAdversaryRoll 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})
}
}
}

View file

@ -143,6 +143,7 @@ export default class D20Roll extends DHRoll {
static postEvaluate(roll, config = {}) {
const data = super.postEvaluate(roll, config);
if (config.targets?.length) {
config.targetSelection = true;
config.targets.forEach(target => {
const difficulty = config.roll.difficulty ?? target.difficulty ?? target.evasion;
target.hit = this.isCritical || roll.total >= difficulty;

View file

@ -74,6 +74,7 @@ export default class DHRoll extends Roll {
}
static postEvaluate(roll, config = {}) {
console.log(roll, config)
return {
type: config.roll.type,
total: roll.total,