This commit is contained in:
WBHarry 2026-05-28 18:38:36 +02:00
parent 7530e4b512
commit 22c3212e5e
4 changed files with 22 additions and 30 deletions

View file

@ -78,6 +78,24 @@ export class DHActionRollData extends foundry.abstract.DataModel {
return formula; return formula;
} }
getModifier() {
const modifiers = [];
if (!this.parent?.actor) return modifiers;
switch (this.parent.actor.type) {
case 'companion':
case 'adversary':
if (this.type === CONFIG.DH.GENERAL.rollTypes.attack.id)
modifiers.push({
label: 'Bonus to Hit',
value: this.bonus ?? this.parent.actor.system.attack.roll.bonus ?? 0
});
break;
default:
break;
}
return modifiers;
}
get rollTrait() { get rollTrait() {
if (this.parent?.actor?.type !== 'character') return null; if (this.parent?.actor?.type !== 'character') return null;
switch (this.type) { switch (this.type) {
@ -127,6 +145,7 @@ export default class RollField extends fields.EmbeddedDataField {
config.dialog.configure = RollField.getAutomation() ? !config.dialog.configure : config.dialog.configure; config.dialog.configure = RollField.getAutomation() ? !config.dialog.configure : config.dialog.configure;
const roll = { const roll = {
baseModifiers: this.roll.getModifier(),
label: 'Attack', label: 'Attack',
type: this.roll?.type, type: this.roll?.type,
trait: this.roll?.rollTrait, trait: this.roll?.rollTrait,

View file

@ -128,30 +128,8 @@ export default class D20Roll extends DHRoll {
} }
} }
getBaseModifiers() {
const modifiers = [];
const actor = foundry.utils.fromUuidSync(this.options.source.actor);
if (!actor) return modifiers;
switch (actor.type) {
case 'companion':
case 'adversary':
if (
this.options.roll.type === CONFIG.DH.GENERAL.rollTypes.attack.id ||
this.options.source.action === actor.system.attack.id
)
modifiers.push({
label: 'Bonus to Hit',
value: this.data.attack.roll.bonus ?? 0
});
break;
default:
break;
}
return modifiers;
}
applyBaseBonus() { applyBaseBonus() {
const modifiers = this.getBaseModifiers(); const modifiers = foundry.utils.deepClone(this.options.roll.baseModifiers) ?? [];
modifiers.push( modifiers.push(
...this.getBonus( ...this.getBonus(

View file

@ -85,6 +85,7 @@ export default class DHRoll extends Roll {
static postEvaluate(roll, config = {}) { static postEvaluate(roll, config = {}) {
return { return {
...roll.options.roll,
total: roll.total, total: roll.total,
formula: roll.formula, formula: roll.formula,
dice: roll.dice.map(d => ({ dice: roll.dice.map(d => ({

View file

@ -132,13 +132,7 @@ export default class DualityRoll extends D20Roll {
} }
createBaseDice() { createBaseDice() {
if ( this.terms = [this.terms[0], this.terms[1], this.terms[2]];
this.dice[0] instanceof game.system.api.dice.diceTypes.HopeDie &&
this.dice[1] instanceof game.system.api.dice.diceTypes.FearDie
) {
this.terms = [this.terms[0], this.terms[1], this.terms[2]];
return;
}
this.terms[0] = new game.system.api.dice.diceTypes.HopeDie({ this.terms[0] = new game.system.api.dice.diceTypes.HopeDie({
faces: this.data.rules.dualityRoll?.defaultHopeDice ?? 12 faces: this.data.rules.dualityRoll?.defaultHopeDice ?? 12