mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Bugfix for item input to resourceDiceDialog
This commit is contained in:
parent
8fc26495c1
commit
b0a0971d0c
3 changed files with 10 additions and 5 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { itemAbleRollParse } from '../../helpers/utils.mjs';
|
||||||
|
|
||||||
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api;
|
||||||
|
|
||||||
export default class ResourceDiceDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
export default class ResourceDiceDialog extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||||
|
|
@ -50,7 +52,7 @@ export default class ResourceDiceDialog extends HandlebarsApplicationMixin(Appli
|
||||||
static async updateResourceDice(event, _, formData) {
|
static async updateResourceDice(event, _, formData) {
|
||||||
const { diceStates } = foundry.utils.expandObject(formData.object);
|
const { diceStates } = foundry.utils.expandObject(formData.object);
|
||||||
this.diceStates = Object.keys(diceStates).reduce((acc, key) => {
|
this.diceStates = Object.keys(diceStates).reduce((acc, key) => {
|
||||||
const resourceState = this.resource.diceStates[key];
|
const resourceState = this.item.system.resource.diceStates[key];
|
||||||
acc[key] = { ...diceStates[key], used: Boolean(resourceState?.used) };
|
acc[key] = { ...diceStates[key], used: Boolean(resourceState?.used) };
|
||||||
return acc;
|
return acc;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
@ -64,7 +66,8 @@ export default class ResourceDiceDialog extends HandlebarsApplicationMixin(Appli
|
||||||
}
|
}
|
||||||
|
|
||||||
static async rerollDice() {
|
static async rerollDice() {
|
||||||
const diceFormula = `${this.resource.max}d${this.resource.dieFaces}`;
|
const max = itemAbleRollParse(this.item.system.resource.max, this.actor, this.item);
|
||||||
|
const diceFormula = `${max}d${this.item.system.resource.dieFaces}`;
|
||||||
const roll = await new Roll(diceFormula).evaluate();
|
const roll = await new Roll(diceFormula).evaluate();
|
||||||
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
|
if (game.modules.get('dice-so-nice')?.active) await game.dice3d.showForRoll(roll, game.user, true);
|
||||||
this.rollValues = roll.terms[0].results.map(x => ({ value: x.result, used: false }));
|
this.rollValues = roll.terms[0].results.map(x => ({ value: x.result, used: false }));
|
||||||
|
|
@ -77,7 +80,7 @@ export default class ResourceDiceDialog extends HandlebarsApplicationMixin(Appli
|
||||||
'systems/daggerheart/templates/ui/chat/resource-roll.hbs',
|
'systems/daggerheart/templates/ui/chat/resource-roll.hbs',
|
||||||
{
|
{
|
||||||
user: this.actor.name,
|
user: this.actor.name,
|
||||||
name: this.name
|
name: this.item.name
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
.resource-items {
|
.resource-items {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
|
||||||
.resource-item {
|
.resource-item {
|
||||||
|
|
@ -51,6 +52,7 @@
|
||||||
|
|
||||||
button {
|
button {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="resource-items">
|
<div class="resource-items">
|
||||||
{{#times (rollParsed item.resource.max actor item numerical=true)}}
|
{{#times (rollParsed item.system.resource.max actor item numerical=true)}}
|
||||||
{{#with (ifThen (lookup ../diceStates this) (lookup ../diceStates this) this) as | state |}}
|
{{#with (ifThen (lookup ../diceStates this) (lookup ../diceStates this) this) as | state |}}
|
||||||
<div class="resource-item" data-dice="{{#if ../../this}}{{../this}}{{else}}{{state}}{{/if}}">
|
<div class="resource-item" data-dice="{{#if ../../this}}{{../this}}{{else}}{{state}}{{/if}}">
|
||||||
<input type="number" data-dtype="Number" name={{concat "diceStates." (ifThen ../../this ../this state) ".value" }} value="{{state.value}}" />
|
<input type="number" data-dtype="Number" name={{concat "diceStates." (ifThen ../../this ../this state) ".value" }} value="{{state.value}}" />
|
||||||
<img src="{{concat "systems/daggerheart/assets/icons/dice/hope/d" (ifThen ../../item.resource.dieFaces ../../item.resource.dieFaces ../item.resource.dieFaces) ".svg"}}" />
|
<img src="{{concat "systems/daggerheart/assets/icons/dice/hope/d" (ifThen ../../item.system.resource.dieFaces ../../item.system.resource.dieFaces ../item.system.resource.dieFaces) ".svg"}}" />
|
||||||
</div>
|
</div>
|
||||||
{{/with}}
|
{{/with}}
|
||||||
{{/times}}
|
{{/times}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue