mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-24 19:39:54 +02:00
Compare commits
No commits in common. "20febb82d5441405315b537ae622af5dbaf5bc17" and "8e4ca52ab779d6392e40c5ef46d789b3e8103a91" have entirely different histories.
20febb82d5
...
8e4ca52ab7
4 changed files with 10 additions and 15 deletions
|
|
@ -254,8 +254,8 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
const target = event.target.closest('[data-die-index]');
|
const target = event.target.closest('[data-die-index]');
|
||||||
|
|
||||||
if (target.dataset.type === 'damage') {
|
if (target.dataset.type === 'damage') {
|
||||||
const { damageType, dice, result } = target.dataset;
|
const { damageType, dice } = target.dataset;
|
||||||
await message.system.damage.rerollDamageDice(damageType, dice, result);
|
await message.system.damage.rerollDamageDice(damageType, dice);
|
||||||
await message.update({
|
await message.update({
|
||||||
'system.damage.types': {
|
'system.damage.types': {
|
||||||
[damageType]: {
|
[damageType]: {
|
||||||
|
|
|
||||||
|
|
@ -59,21 +59,20 @@ class ChatMessageRollDamage extends foundry.abstract.DataModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async rerollDamageDice(damageType, dice, resultIndex) {
|
async rerollDamageDice(damageType, dice) {
|
||||||
const reroll = this.types[damageType].roll;
|
const reroll = this.types[damageType].roll;
|
||||||
const rerollDice = reroll.dice[dice];
|
const rerollDice = reroll.dice[dice];
|
||||||
const diceResult = rerollDice.results[resultIndex];
|
await rerollDice.reroll(`/r1=${rerollDice.total}`);
|
||||||
await rerollDice.reroll(`/r1=${diceResult.result}`);
|
|
||||||
await reroll._evaluate();
|
await reroll._evaluate();
|
||||||
|
|
||||||
const rerolledResult = rerollDice.results[rerollDice.results.length - 1];
|
const result = rerollDice.results.find(x => x.active);
|
||||||
if (rerolledResult) {
|
if (result) {
|
||||||
const fakeRoll = {
|
const fakeRoll = {
|
||||||
_evaluated: true,
|
_evaluated: true,
|
||||||
dice: [new foundry.dice.terms.Die({
|
dice: [new foundry.dice.terms.Die({
|
||||||
...rerollDice,
|
...rerollDice,
|
||||||
results: [rerolledResult],
|
results: [result],
|
||||||
total: rerolledResult.value,
|
total: result.value,
|
||||||
faces: rerollDice.faces
|
faces: rerollDice.faces
|
||||||
})],
|
})],
|
||||||
options: { appearance: {} }
|
options: { appearance: {} }
|
||||||
|
|
|
||||||
|
|
@ -19,15 +19,11 @@ export default class DamageRoll extends DHRoll {
|
||||||
|
|
||||||
for (const roll of config.roll) {
|
for (const roll of config.roll) {
|
||||||
await roll.roll.evaluate();
|
await roll.roll.evaluate();
|
||||||
|
|
||||||
if (!config.damage?.types) config.damage = { types: {} };
|
|
||||||
config.damage.types[roll.applyTo] = {
|
config.damage.types[roll.applyTo] = {
|
||||||
roll: roll.roll,
|
roll: roll.roll,
|
||||||
damageTypes: roll.damageTypes ?? []
|
damageTypes: roll.damageTypes ?? []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
roll._evaluated = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static async buildPost(roll, config, message) {
|
static async buildPost(roll, config, message) {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
<div class="roll-die{{#unless @../first}} has-plus{{/unless}}">
|
<div class="roll-die{{#unless @../first}} has-plus{{/unless}}">
|
||||||
<div
|
<div
|
||||||
class="dice reroll-button {{../dice}}"
|
class="dice reroll-button {{../dice}}"
|
||||||
data-die-index="0" data-type="damage" data-damage-type="{{@../../key}}" data-dice="{{@../key}}" data-result="{{@key}}"
|
data-die-index="0" data-type="damage" data-damage-type="{{@../../key}}" data-dice="{{@../key}}"
|
||||||
>
|
>
|
||||||
{{#if hasRerolls}}<i class="fa-solid fa-dice dice-rerolled" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerolled"}}"></i>{{/if}}
|
{{#if hasRerolls}}<i class="fa-solid fa-dice dice-rerolled" data-tooltip="{{localize "DAGGERHEART.GENERAL.rerolled"}}"></i>{{/if}}
|
||||||
{{result}}
|
{{result}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue