From 8fc44912facb0abe3173056f14a26605d9f19a34 Mon Sep 17 00:00:00 2001 From: Apewall <1915182+apewall@users.noreply.github.com> Date: Thu, 18 Jan 2024 15:03:11 -0600 Subject: [PATCH 1/5] Get spell dice rolling --- src/module/helpers-dice.js | 1 + src/module/item/entity.js | 31 ++++++++++++++++++++--------- src/templates/chat/roll-result.html | 20 +++++++++++++++++-- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/module/helpers-dice.js b/src/module/helpers-dice.js index effb09b0..7837e9c9 100644 --- a/src/module/helpers-dice.js +++ b/src/module/helpers-dice.js @@ -24,6 +24,7 @@ const OseDice = { title, flavor, data, + config: CONFIG.OSE, }; // Optionally include a situational bonus diff --git a/src/module/item/entity.js b/src/module/item/entity.js index e850a073..f4baeca3 100644 --- a/src/module/item/entity.js +++ b/src/module/item/entity.js @@ -138,32 +138,40 @@ export default class OseItem extends Item { } async rollFormula(options = {}) { - const data = this.system; + const itemData = this.system; - if (!data.roll) { + if (!itemData.roll) { throw new Error("This Item does not have a formula to roll!"); } const label = `${this.name}`; - const rollParts = [data.roll]; + const rollParts = [itemData.roll]; - const type = data.rollType; + const type = itemData.rollType; - const newData = { + const rollData = { actor: this.actor, item: this._source, + description: null, + save: itemData.save, + properties: this.system.autoTags, roll: { type, - target: data.rollTarget, - blindroll: data.blindroll, + target: itemData.rollTarget, + blindroll: itemData.blindroll, + save: itemData.save, }, }; + if (this.type === "spell") { + rollData.description = itemData.description + }; + // Roll and return return OseDice.Roll({ event: options.event, parts: rollParts, - data: newData, + data: rollData, skipDialog: true, speaker: ChatMessage.getSpeaker({ actor: this }), flavor: game.i18n.format("OSE.roll.formula", { label }), @@ -183,7 +191,12 @@ export default class OseItem extends Item { cast: itemData.cast - 1, }, }); - await this.show({ skipDialog: true }); + + if (itemData.roll) { + await this.rollFormula() + } else { + await this.show({ skipDialog: true }) + }; } _getRollTag(data) { diff --git a/src/templates/chat/roll-result.html b/src/templates/chat/roll-result.html index efe8863a..66ce1fe1 100644 --- a/src/templates/chat/roll-result.html +++ b/src/templates/chat/roll-result.html @@ -1,4 +1,5 @@ -
+

{{title}}

@@ -8,6 +9,9 @@
{{/if}}
+
+ {{{data.description}}} +
{{#if result.details}}
{{{result.details}}}
{{/if}} {{#if result.isFailure}}
{{localize 'OSE.Failure'}} ({{result.target}}) @@ -15,6 +19,18 @@ {{#if result.isSuccess}}
{{localize 'OSE.Success'}} ({{result.target}})
{{/if}} {{#if rollOSE}}
{{{rollOSE}}}
{{/if}} +
+ {{#if data.save}} + + {{/if}} +
+
-
\ No newline at end of file + From 637ae2652594315297d14d61fde24eb3d019d5d3 Mon Sep 17 00:00:00 2001 From: Apewall <1915182+apewall@users.noreply.github.com> Date: Thu, 8 Feb 2024 20:06:36 -0600 Subject: [PATCH 2/5] Only include button template when saves exist --- src/templates/chat/roll-result.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/templates/chat/roll-result.html b/src/templates/chat/roll-result.html index 66ce1fe1..6c614cff 100644 --- a/src/templates/chat/roll-result.html +++ b/src/templates/chat/roll-result.html @@ -19,13 +19,13 @@ {{#if result.isSuccess}}
{{localize 'OSE.Success'}} ({{result.target}})
{{/if}} {{#if rollOSE}}
{{{rollOSE}}}
{{/if}} + {{#if data.save}}
- {{#if data.save}} - {{/if}}
+ {{/if}}