mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-21 18:09:54 +02:00
Semi-corrected reroll of one of multiple results on a die
This commit is contained in:
parent
fea3671069
commit
20febb82d5
3 changed files with 11 additions and 10 deletions
|
|
@ -254,8 +254,8 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
const target = event.target.closest('[data-die-index]');
|
||||
|
||||
if (target.dataset.type === 'damage') {
|
||||
const { damageType, dice } = target.dataset;
|
||||
await message.system.damage.rerollDamageDice(damageType, dice);
|
||||
const { damageType, dice, result } = target.dataset;
|
||||
await message.system.damage.rerollDamageDice(damageType, dice, result);
|
||||
await message.update({
|
||||
'system.damage.types': {
|
||||
[damageType]: {
|
||||
|
|
|
|||
|
|
@ -59,20 +59,21 @@ class ChatMessageRollDamage extends foundry.abstract.DataModel {
|
|||
}
|
||||
}
|
||||
|
||||
async rerollDamageDice(damageType, dice) {
|
||||
async rerollDamageDice(damageType, dice, resultIndex) {
|
||||
const reroll = this.types[damageType].roll;
|
||||
const rerollDice = reroll.dice[dice];
|
||||
await rerollDice.reroll(`/r1=${rerollDice.total}`);
|
||||
const diceResult = rerollDice.results[resultIndex];
|
||||
await rerollDice.reroll(`/r1=${diceResult.result}`);
|
||||
await reroll._evaluate();
|
||||
|
||||
const result = rerollDice.results.find(x => x.active);
|
||||
if (result) {
|
||||
|
||||
const rerolledResult = rerollDice.results[rerollDice.results.length - 1];
|
||||
if (rerolledResult) {
|
||||
const fakeRoll = {
|
||||
_evaluated: true,
|
||||
dice: [new foundry.dice.terms.Die({
|
||||
...rerollDice,
|
||||
results: [result],
|
||||
total: result.value,
|
||||
results: [rerolledResult],
|
||||
total: rerolledResult.value,
|
||||
faces: rerollDice.faces
|
||||
})],
|
||||
options: { appearance: {} }
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<div class="roll-die{{#unless @../first}} has-plus{{/unless}}">
|
||||
<div
|
||||
class="dice reroll-button {{../dice}}"
|
||||
data-die-index="0" data-type="damage" data-damage-type="{{@../../key}}" data-dice="{{@../key}}"
|
||||
data-die-index="0" data-type="damage" data-damage-type="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}"
|
||||
>
|
||||
{{#if hasRerolls}}<i class="fa-solid fa-dice dice-rerolled" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerolled"}}"></i>{{/if}}
|
||||
{{result}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue