diff --git a/lang/en.json b/lang/en.json index 23150432..5d41f022 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2015,6 +2015,7 @@ }, "title": "Title", "total": "Total", + "traitModifier": "Trait Modifier", "true": "True", "type": "Type", "unarmed": "Unarmed", diff --git a/module/applications/dialogs/d20RollDialog.mjs b/module/applications/dialogs/d20RollDialog.mjs index 1f4bf16c..2b048218 100644 --- a/module/applications/dialogs/d20RollDialog.mjs +++ b/module/applications/dialogs/d20RollDialog.mjs @@ -1,3 +1,5 @@ +import { abilities } from "../../config/actorConfig.mjs"; + const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api; export default class D20RollDialog extends HandlebarsApplicationMixin(ApplicationV2) { @@ -113,15 +115,21 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio context.isLite = this.config.roll?.lite; context.extraFormula = this.config.extraFormula; context.formula = this.roll.constructFormula(this.config); + if(this.actor.system.traits) context.abilities = this.getTraitModifiers(); - context.showReaction = !context.config.roll?.type && context.rollType === 'DualityRoll'; + context.showReaction = !this.config.roll?.type && context.rollType === 'DualityRoll'; context.reactionOverride = this.reactionOverride; } return context; } + getTraitModifiers() { + return Object.values(abilities).map(a => ({ id: a.id, label: `${game.i18n.localize(a.label)} (${this.actor.system.traits[a.id]?.value.signedString() ?? 0})` })) + } + static updateRollConfiguration(event, _, formData) { const { ...rest } = foundry.utils.expandObject(formData.object); + this.config.selectedRollMode = rest.selectedRollMode; if (this.config.costs) { @@ -133,6 +141,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio this.roll[key] = value; }); } + if(rest.trait) this.config.roll.trait = rest.trait; this.config.extraFormula = rest.extraFormula; this.render(); } diff --git a/module/data/fields/action/rollField.mjs b/module/data/fields/action/rollField.mjs index daae4a25..4cc50777 100644 --- a/module/data/fields/action/rollField.mjs +++ b/module/data/fields/action/rollField.mjs @@ -72,27 +72,27 @@ export class DHActionRollData extends foundry.abstract.DataModel { if (!this.parent?.actor) return modifiers; switch (this.parent.actor.type) { case 'character': - const spellcastingTrait = - this.type === 'spellcast' - ? (this.parent.actor?.system?.spellcastModifierTrait?.key ?? 'agility') - : null; - const trait = - this.useDefault || !this.trait - ? (spellcastingTrait ?? this.parent.item.system.attack?.roll?.trait ?? 'agility') - : this.trait; - if ( - this.type === CONFIG.DH.GENERAL.rollTypes.attack.id || - this.type === CONFIG.DH.GENERAL.rollTypes.trait.id - ) - modifiers.push({ - label: `DAGGERHEART.CONFIG.Traits.${trait}.name`, - value: this.parent.actor.system.traits[trait].value - }); - else if (this.type === CONFIG.DH.GENERAL.rollTypes.spellcast.id) - modifiers.push({ - label: `DAGGERHEART.CONFIG.RollTypes.spellcast.name`, - value: this.parent.actor.system.spellcastModifier - }); + // const spellcastingTrait = + // this.type === 'spellcast' + // ? (this.parent.actor?.system?.spellcastModifierTrait?.key ?? 'agility') + // : null; + // const trait = + // this.useDefault || !this.trait + // ? (spellcastingTrait ?? this.parent.item.system.attack?.roll?.trait ?? 'agility') + // : this.trait; + // if ( + // this.type === CONFIG.DH.GENERAL.rollTypes.attack.id || + // this.type === CONFIG.DH.GENERAL.rollTypes.trait.id + // ) + // modifiers.push({ + // label: `DAGGERHEART.CONFIG.Traits.${trait}.name`, + // value: this.parent.actor.system.traits[trait].value + // }); + // else if (this.type === CONFIG.DH.GENERAL.rollTypes.spellcast.id) + // modifiers.push({ + // label: `DAGGERHEART.CONFIG.RollTypes.spellcast.name`, + // value: this.parent.actor.system.spellcastModifier + // }); break; case 'companion': case 'adversary': @@ -107,6 +107,21 @@ export class DHActionRollData extends foundry.abstract.DataModel { } return modifiers; } + + get rollTrait() { + if(this.parent?.actor?.type !== "character") return null; + switch (this.type) { + case CONFIG.DH.GENERAL.rollTypes.spellcast.id: + return this.parent.actor?.system?.spellcastModifierTrait?.key ?? 'agility'; + case CONFIG.DH.GENERAL.rollTypes.attack.id: + case CONFIG.DH.GENERAL.rollTypes.trait.id: + return this.useDefault || !this.trait + ? this.parent.item.system.attack?.roll?.trait ?? 'agility' + : this.trait; + default: + return null; + } + } } export default class RollField extends fields.EmbeddedDataField { @@ -145,6 +160,7 @@ export default class RollField extends fields.EmbeddedDataField { baseModifiers: this.roll.getModifier(), label: 'Attack', type: this.roll?.type, + trait: this.roll?.rollTrait, difficulty: this.roll?.difficulty, formula: this.roll.getFormula(), advantage: CONFIG.DH.ACTIONS.advantageState[this.roll.advState].value diff --git a/module/dice/dualityRoll.mjs b/module/dice/dualityRoll.mjs index b3fa16c2..9e185779 100644 --- a/module/dice/dualityRoll.mjs +++ b/module/dice/dualityRoll.mjs @@ -153,10 +153,10 @@ export default class DualityRoll extends D20Roll { applyBaseBonus() { const modifiers = super.applyBaseBonus(); - + if (this.options.roll.trait && this.data.traits[this.options.roll.trait]) modifiers.unshift({ - label: `DAGGERHEART.CONFIG.Traits.${this.options.roll.trait}.name`, + label: this.options.roll.type === CONFIG.DH.GENERAL.rollTypes.spellcast.id ? "DAGGERHEART.CONFIG.RollTypes.spellcast.name" : `DAGGERHEART.CONFIG.Traits.${this.options.roll.trait}.name`, value: this.data.traits[this.options.roll.trait].value }); diff --git a/templates/actionTypes/save.hbs b/templates/actionTypes/save.hbs index 90bc0483..3980cc99 100644 --- a/templates/actionTypes/save.hbs +++ b/templates/actionTypes/save.hbs @@ -1,5 +1,5 @@