Added a toggle in D20RollDialog for ReactionRolls

This commit is contained in:
WBHarry 2025-07-30 15:22:35 +02:00
parent 8e516df7cb
commit 9cb8302bcd
6 changed files with 54 additions and 7 deletions

View file

@ -1393,6 +1393,7 @@
"proficiency": "Proficiency", "proficiency": "Proficiency",
"quantity": "Quantity", "quantity": "Quantity",
"range": "Range", "range": "Range",
"reactionRoll": "Reaction Roll",
"recovery": "Recovery", "recovery": "Recovery",
"reroll": "Reroll", "reroll": "Reroll",
"rerollThing": "Reroll {thing}", "rerollThing": "Reroll {thing}",

View file

@ -7,6 +7,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
this.roll = roll; this.roll = roll;
this.config = config; this.config = config;
this.config.experiences = []; this.config.experiences = [];
this.reactionOverride = false;
if (config.source?.action) { if (config.source?.action) {
this.item = config.data.parent.items.get(config.source.item) ?? config.data.parent; 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: { actions: {
updateIsAdvantage: this.updateIsAdvantage, updateIsAdvantage: this.updateIsAdvantage,
selectExperience: this.selectExperience, selectExperience: this.selectExperience,
toggleReaction: this.toggleReaction,
submitRoll: this.submitRoll submitRoll: this.submitRoll
}, },
form: { form: {
@ -103,6 +105,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
context.isLite = this.config.roll?.lite; context.isLite = this.config.roll?.lite;
context.extraFormula = this.config.extraFormula; context.extraFormula = this.config.extraFormula;
context.formula = this.roll.constructFormula(this.config); context.formula = this.roll.constructFormula(this.config);
context.reactionOverride = this.reactionOverride;
} }
return context; return context;
} }
@ -141,7 +144,15 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
this.render(); this.render();
} }
static toggleReaction() {
if (this.config.roll) {
this.reactionOverride = !this.reactionOverride;
this.render();
}
}
static async submitRoll() { static async submitRoll() {
this.config.roll.type = this.reactionOverride ? CONFIG.DH.ITEM.actionTypes.reaction.id : this.config.roll.type;
await this.close({ submitted: true }); await this.close({ submitted: true });
} }

View file

@ -69,6 +69,7 @@ export default class DHRoll extends Roll {
static postEvaluate(roll, config = {}) { static postEvaluate(roll, config = {}) {
return { return {
type: config.roll.type,
total: roll.total, total: roll.total,
formula: roll.formula, formula: roll.formula,
dice: roll.dice.map(d => ({ dice: roll.dice.map(d => ({
@ -194,7 +195,8 @@ export const registerRollDiceHooks = () => {
if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1 }); if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1 });
if (config.rerolledRoll) { 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.isCritical) updates.push({ key: 'stress', value: 1 });
if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1 }); if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1 });
} }

View file

@ -9,6 +9,36 @@
} }
.application.daggerheart.dialog.dh-style.views.roll-selection { .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 { .roll-dialog-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -16,6 +46,7 @@
max-width: 550px; max-width: 550px;
.dices-section { .dices-section {
position: relative;
display: flex; display: flex;
gap: 60px; gap: 60px;
justify-content: center; justify-content: center;

View file

@ -1,7 +1,8 @@
<header class="dialog-header"> <header class="dialog-header">
{{#if rollConfig.headerTitle}} <h1>
<h1>{{rollConfig.headerTitle}}</h1> {{ifThen rollConfig.headerTitle rollConfig.headerTitle rollConfig.title}}
{{else}} <button class="reaction-roll-controller {{#if reactionOverride}}active{{/if}}" data-action="toggleReaction" data-tooltip-text="{{localize "DAGGERHEART.GENERAL.reactionRoll"}}">
<h1>{{rollConfig.title}}</h1> <i class="fa-solid fa-reply"></i>
{{/if}} </button>
</h1>
</header> </header>

View file

@ -40,6 +40,7 @@
</select> </select>
</div> </div>
</div> </div>
<div class="dice-option"> <div class="dice-option">
<img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/fear/' @root.roll.dFear.denomination '.svg'}}" alt=""> <img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/fear/' @root.roll.dFear.denomination '.svg'}}" alt="">
<div class="dice-select"> <div class="dice-select">