diff --git a/lang/en.json b/lang/en.json index 9afa7a62..be761dab 100755 --- a/lang/en.json +++ b/lang/en.json @@ -1393,6 +1393,7 @@ "proficiency": "Proficiency", "quantity": "Quantity", "range": "Range", + "reactionRoll": "Reaction Roll", "recovery": "Recovery", "reroll": "Reroll", "rerollThing": "Reroll {thing}", diff --git a/module/applications/dialogs/d20RollDialog.mjs b/module/applications/dialogs/d20RollDialog.mjs index 76871b6a..75253215 100644 --- a/module/applications/dialogs/d20RollDialog.mjs +++ b/module/applications/dialogs/d20RollDialog.mjs @@ -7,6 +7,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio this.roll = roll; this.config = config; this.config.experiences = []; + this.reactionOverride = false; if (config.source?.action) { this.item = config.data.parent.items.get(config.source.item) ?? config.data.parent; @@ -30,6 +31,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio actions: { updateIsAdvantage: this.updateIsAdvantage, selectExperience: this.selectExperience, + toggleReaction: this.toggleReaction, submitRoll: this.submitRoll }, form: { @@ -103,6 +105,7 @@ 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); + context.reactionOverride = this.reactionOverride; } return context; } @@ -141,7 +144,15 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio this.render(); } + static toggleReaction() { + if (this.config.roll) { + this.reactionOverride = !this.reactionOverride; + this.render(); + } + } + static async submitRoll() { + this.config.roll.type = this.reactionOverride ? CONFIG.DH.ITEM.actionTypes.reaction.id : this.config.roll.type; await this.close({ submitted: true }); } diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index aa1ebb68..fcf30be5 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -69,6 +69,7 @@ export default class DHRoll extends Roll { static postEvaluate(roll, config = {}) { return { + type: config.roll.type, total: roll.total, formula: roll.formula, dice: roll.dice.map(d => ({ @@ -194,11 +195,12 @@ export const registerRollDiceHooks = () => { if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1 }); if (config.rerolledRoll) { - if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1) updates.push({ key: 'hope', value: -1 }); + if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1) + updates.push({ key: 'hope', value: -1 }); if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: 1 }); if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1 }); } - + if (updates.length) { const target = actor.system.partner ?? actor; if (!['dead', 'unconcious'].some(x => actor.statuses.has(x))) { diff --git a/styles/less/dialog/dice-roll/roll-selection.less b/styles/less/dialog/dice-roll/roll-selection.less index 4ee2ee1f..d536ee04 100644 --- a/styles/less/dialog/dice-roll/roll-selection.less +++ b/styles/less/dialog/dice-roll/roll-selection.less @@ -9,6 +9,36 @@ } .application.daggerheart.dialog.dh-style.views.roll-selection { + .dialog-header { + display: flex; + justify-content: center; + + h1 { + width: auto; + display: flex; + align-items: center; + gap: 8px; + + .reaction-roll-controller { + width: auto; + opacity: 0.3; + border-radius: 50%; + font-size: 18px; + font-weight: bold; + + &:hover { + opacity: 0.5; + background: light-dark(transparent, @golden); + color: light-dark(@dark-blue, @dark-blue); + } + + &.active { + opacity: 1; + } + } + } + } + .roll-dialog-container { display: flex; flex-direction: column; @@ -16,6 +46,7 @@ max-width: 550px; .dices-section { + position: relative; display: flex; gap: 60px; justify-content: center; diff --git a/templates/dialogs/dice-roll/header.hbs b/templates/dialogs/dice-roll/header.hbs index 462408f6..eceb8c89 100644 --- a/templates/dialogs/dice-roll/header.hbs +++ b/templates/dialogs/dice-roll/header.hbs @@ -1,7 +1,8 @@
- {{#if rollConfig.headerTitle}} -

{{rollConfig.headerTitle}}

- {{else}} -

{{rollConfig.title}}

- {{/if}} +

+ {{ifThen rollConfig.headerTitle rollConfig.headerTitle rollConfig.title}} + +

\ No newline at end of file diff --git a/templates/dialogs/dice-roll/rollSelection.hbs b/templates/dialogs/dice-roll/rollSelection.hbs index 995be022..e517bc6d 100644 --- a/templates/dialogs/dice-roll/rollSelection.hbs +++ b/templates/dialogs/dice-roll/rollSelection.hbs @@ -40,6 +40,7 @@ +