[Feature] Allow Dice Reroll in ChatMessage (#395)

* Troubleshooting

Created test button in 'duality-roll.hbs' and functionality in chatLog.mjs

* Updated functionality

dialog recheck.

* Update duality-roll.hbs

testing toggle on specific areas so only tooltip is triggered.

Rest of CSS functionality not affected.

* Redoing Dice Reroll functionality

Attempting something new

* The rise of NaNs

Resolved Dice Parsing Errors, now dealing with parsing errors from system values.

* Forcing string evaluation for testing

* Fixed rerolling of duality dice

* Fixed message.rolls not being updated

* Added support for d20 rolls

* PR fixes

---------

Co-authored-by: Nikhil Nagarajan <potter.nikhil@gmail.com>
This commit is contained in:
WBHarry 2025-07-23 01:01:21 +02:00 committed by GitHub
parent 2721dfe417
commit 6301e575e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 593 additions and 490 deletions

View file

@ -12,16 +12,13 @@
<span class="part-total">{{total}}</span>
</header>
<div class="flexrow">
<ol class="dice-rolls">
{{#each results}}
<li class="roll die {{../dice}}{{#if discarded}} discarded{{/if}} min">{{result}}</li>
{{/each}}
<ol class="dice-rolls rerollable">
<button type="checkbox" class="reroll-button" data-die-index="0" data-tooltip="{{localize "DAGGERHEART.GENERAL.reroll"}}">
{{#each results as |result index|}}
<li class="roll die {{../dice}}{{#if discarded}} discarded{{/if}} min">{{result.result}}</li>
{{/each}}
</button>
</ol>
{{#if (eq index 0)}}
<div class="attack-roll-advantage-container">
{{#if (eq ../roll.advantage.type 1)}}{{localize "DAGGERHEART.GENERAL.Advantage.full"}}{{/if}}{{#if (eq ../roll.advantage.type -1)}}{{localize "DAGGERHEART.GENERAL.Disadvantage.full"}}{{/if}}
</div>
{{/if}}
</div>
{{/each}}
</div>

View file

@ -1,6 +1,6 @@
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
<div class="dice-flavor">{{title}}</div>
<div class="duality-modifiers">
<div class="dice-roll daggerheart chat roll" data-action="expandRoll">
<div class="dice-flavor" data-action="expandRoll">{{title}}</div>
<div class="duality-modifiers" data-action="expandRoll">
{{#each roll.modifiers}}
<div class="duality-modifier">
{{localize label}} {{#if (gte value 0)}}+{{/if}}{{value}}
@ -22,12 +22,12 @@
</div>
{{/if}}
</div>
<div class="dice-result">
<div class="dice-formula">{{roll.formula}}</div>
<div class="dice-result">
<div class="dice-formula" data-action="expandRoll">{{roll.formula}}</div>
<div class="dice-tooltip">
<div class="wrapper">
<section class="tooltip-part">
<div class="dice">
<div class="dice" data-action="expandRoll">
<header class="part-header flexrow">
<span class="part-formula">
<span>1{{roll.hope.dice}}</span>
@ -38,25 +38,29 @@
</header>
<div class="flexrow">
<ol class="dice-rolls duality">
<li class="roll die {{roll.hope.dice}}" title="{{localize "DAGGERHEART.GENERAL.hope"}}">
<li class="roll die {{roll.hope.dice}}">
<div class="dice-container">
<div class="dice-title">{{localize "DAGGERHEART.GENERAL.hope"}}</div>
<div class="dice-inner-container hope" title="{{localize "DAGGERHEART.GENERAL.hope"}}">
<div class="dice-wrapper">
<img class="dice" src="../icons/svg/{{roll.hope.dice}}-grey.svg"/>
</div>
<div class="dice-value">{{roll.hope.value}}</div>
<div class="dice-inner-container hope" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerollThing" thing=(localize "DAGGERHEART.GENERAL.hope")}}">
<button type="checkbox" class="reroll-button" data-die-index="0" data-type="hope">
<div class="dice-wrapper">
<img class="dice" src="../icons/svg/{{roll.hope.dice}}-grey.svg"/>
</div>
<div class="dice-value">{{roll.hope.value}}</div>
</button>
</div>
</div>
</li>
<li class="roll die {{roll.fear.dice}}" title="{{localize "DAGGERHEART.GENERAL.fear"}}">
<li class="roll die {{roll.fear.dice}}">
<div class="dice-container">
<div class="dice-title">{{localize "DAGGERHEART.GENERAL.fear"}}</div>
<div class="dice-inner-container fear" title="{{localize "DAGGERHEART.GENERAL.fear"}}">
<div class="dice-wrapper">
<img class="dice" src="../icons/svg/{{roll.fear.dice}}-grey.svg"/>
</div>
<div class="dice-value">{{roll.fear.value}}</div>
<div class="dice-inner-container fear" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerollThing" thing=(localize "DAGGERHEART.GENERAL.fear")}}">
<button type="checkbox" class="reroll-button" data-die-index="2" data-type="fear">
<div class="dice-wrapper">
<img class="dice" src="../icons/svg/{{roll.fear.dice}}-grey.svg"/>
</div>
<div class="dice-value">{{roll.fear.value}}</div>
</button>
</div>
</div>
</li>
@ -64,7 +68,7 @@
</div>
</div>
{{#if roll.advantage.type}}
<div class="dice">
<div class="dice" data-action="expandRoll">
<header class="part-header flexrow">
<span class="part-formula">
<span>1{{roll.advantage.dice}}</span>
@ -112,7 +116,7 @@
</div>
{{/if}}
{{#each roll.extra as | extra | }}
<div class="dice">
<div class="dice" data-action="expandRoll">
<header class="part-header flexrow">
<span class="part-formula">
<span>1{{extra.dice}}</span>
@ -200,4 +204,4 @@
</div>
</div>
</div>
</div>
</div>