diff --git a/module/data/action/macroAction.mjs b/module/data/action/macroAction.mjs index c4a08df7..58b8eba5 100644 --- a/module/data/action/macroAction.mjs +++ b/module/data/action/macroAction.mjs @@ -1,19 +1,13 @@ import DHBaseAction from './baseAction.mjs'; export default class DHMacroAction extends DHBaseAction { - static defineSchema() { - const fields = foundry.data.fields; - return { - ...super.defineSchema(), - documentUUID: new fields.DocumentUUIDField({ type: 'Macro' }) - }; - } + static extraSchemas = [...super.extraSchemas, 'macro']; async trigger(event, ...args) { - const fixUUID = !this.documentUUID.includes('Macro.') ? `Macro.${this.documentUUID}` : this.documentUUID, + const fixUUID = !this.macro.includes('Macro.') ? `Macro.${this.macro}` : this.macro, macro = await fromUuid(fixUUID); try { - if (!macro) throw new Error(`No macro found for the UUID: ${this.documentUUID}.`); + if (!macro) throw new Error(`No macro found for the UUID: ${this.macro}.`); macro.execute(); } catch (error) { ui.notifications.error(error); diff --git a/module/data/fields/action/_module.mjs b/module/data/fields/action/_module.mjs index 192341e7..e6caa963 100644 --- a/module/data/fields/action/_module.mjs +++ b/module/data/fields/action/_module.mjs @@ -8,3 +8,4 @@ export { default as BeastformField } from './beastformField.mjs'; export { default as DamageField } from './damageField.mjs'; export { default as HealingField } from './healingField.mjs'; export { default as RollField } from './rollField.mjs'; +export { default as MacroField } from './macroField.mjs'; diff --git a/module/data/fields/action/macroField.mjs b/module/data/fields/action/macroField.mjs new file mode 100644 index 00000000..62da0da0 --- /dev/null +++ b/module/data/fields/action/macroField.mjs @@ -0,0 +1,7 @@ +const fields = foundry.data.fields; + +export default class MacroField extends fields.DocumentUUIDField { + constructor(context = {}) { + super({ type: "Macro" }, context); + } +} diff --git a/module/data/fields/actionField.mjs b/module/data/fields/actionField.mjs index 8d865562..dc567da9 100644 --- a/module/data/fields/actionField.mjs +++ b/module/data/fields/actionField.mjs @@ -84,7 +84,7 @@ export class ActionField extends foundry.data.fields.ObjectField { getModel(value) { return ( game.system.api.models.actions.actionsTypes[value.type] ?? - game.system.api.models.actions.actionsTypes.attack + null ); } @@ -93,7 +93,6 @@ export class ActionField extends foundry.data.fields.ObjectField { /** @override */ _cleanType(value, options) { if (!(typeof value === 'object')) value = {}; - const cls = this.getModel(value); if (cls) return cls.cleanData(value, options); return value; diff --git a/module/documents/chatMessage.mjs b/module/documents/chatMessage.mjs index 2b10e251..398bfcbe 100644 --- a/module/documents/chatMessage.mjs +++ b/module/documents/chatMessage.mjs @@ -70,9 +70,13 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage { } } - if(!game.user.isGM && !this.isAuthor && !this.speakerActor?.isOwner) { - const buttons = html.querySelectorAll(".ability-card-footer > .ability-use-button"); - buttons.forEach(b => b.remove()); + if(!game.user.isGM) { + const applyButtons = html.querySelector(".apply-buttons"); + applyButtons.remove(); + if(!this.isAuthor && !this.speakerActor?.isOwner) { + const buttons = html.querySelectorAll(".ability-card-footer > .ability-use-button"); + buttons.forEach(b => b.remove()); + } } } diff --git a/module/systemRegistration/handlebars.mjs b/module/systemRegistration/handlebars.mjs index 48a99735..ff741b91 100644 --- a/module/systemRegistration/handlebars.mjs +++ b/module/systemRegistration/handlebars.mjs @@ -15,9 +15,8 @@ export const preloadHandlebarsTemplates = async function () { 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs', 'systems/daggerheart/templates/ui/combatTracker/combatTrackerSection.hbs', 'systems/daggerheart/templates/actionTypes/damage.hbs', - 'systems/daggerheart/templates/actionTypes/healing.hbs', 'systems/daggerheart/templates/actionTypes/resource.hbs', - 'systems/daggerheart/templates/actionTypes/uuid.hbs', + 'systems/daggerheart/templates/actionTypes/macro.hbs', 'systems/daggerheart/templates/actionTypes/uses.hbs', 'systems/daggerheart/templates/actionTypes/roll.hbs', 'systems/daggerheart/templates/actionTypes/save.hbs', diff --git a/templates/actionTypes/healing.hbs b/templates/actionTypes/healing.hbs deleted file mode 100644 index 4b8023d7..00000000 --- a/templates/actionTypes/healing.hbs +++ /dev/null @@ -1,41 +0,0 @@ - -
- - {{localize "DAGGERHEART.GENERAL.healing"}} - - {{#if (and (not @root.isNPC) @root.hasRoll)}} - {{formField fields.resultBased value=source.resultBased name="healing.resultBased" localize=true classes="checkbox"}} - {{/if}} - {{#if (and (not @root.isNPC) @root.hasRoll source.resultBased)}} -
-
- -
{{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.hope")}}
-
- {{> formula fields=fields.value.fields source=source.value target="value"}} -
-
- -
{{localize "DAGGERHEART.GENERAL.withThing" thing=(localize "DAGGERHEART.GENERAL.fear")}}
-
- {{> formula fields=fields.valueAlt.fields source=source.valueAlt target="valueAlt"}} -
-
- {{else}} - {{> formula fields=fields.value.fields source=source.value target="value"}} - {{/if}} - {{formField fields.applyTo value=source.applyTo name="healing.applyTo" localize=true}} -
- -{{#*inline "formula"}} - {{formField fields.custom.fields.enabled value=source.custom.enabled name=(concat "healing." target ".custom.enabled") classes="checkbox"}} - {{#if source.custom.enabled}} - {{formField fields.custom.fields.formula value=source.custom.formula name=(concat "healing." target ".custom.formula") localize=true}} - {{else}} -
- {{formField fields.multiplier value=source.multiplier name=(concat "healing." target ".multiplier") localize=true}} - {{formField fields.dice value=source.dice name=(concat "healing." target ".dice")}} - {{formField fields.bonus value=source.bonus name=(concat "healing." target ".bonus") localize=true}} -
- {{/if}} -{{/inline}} \ No newline at end of file diff --git a/templates/actionTypes/macro.hbs b/templates/actionTypes/macro.hbs new file mode 100644 index 00000000..8c984be8 --- /dev/null +++ b/templates/actionTypes/macro.hbs @@ -0,0 +1,5 @@ + +
+ {{localize "DOCUMENT.Macro"}} + {{formInput fields name="macro" value=source}} +
\ No newline at end of file diff --git a/templates/actionTypes/uuid.hbs b/templates/actionTypes/uuid.hbs deleted file mode 100644 index 140cad78..00000000 --- a/templates/actionTypes/uuid.hbs +++ /dev/null @@ -1,9 +0,0 @@ - -
- -
{{localize "DOCUMENT.Macro"}}
-
-
- {{formInput fields value=source name="documentUUID" placeholder=fields.options.placeholder}} -
-
\ No newline at end of file diff --git a/templates/sheets-settings/action-settings/effect.hbs b/templates/sheets-settings/action-settings/effect.hbs index f2bc6c0f..9cb2e6c2 100644 --- a/templates/sheets-settings/action-settings/effect.hbs +++ b/templates/sheets-settings/action-settings/effect.hbs @@ -6,9 +6,8 @@ {{#if fields.roll}}{{> 'systems/daggerheart/templates/actionTypes/roll.hbs' fields=fields.roll.fields source=source.roll}}{{/if}} {{#if fields.save}}{{> 'systems/daggerheart/templates/actionTypes/save.hbs' fields=fields.save.fields source=source.save}}{{/if}} {{#if fields.damage}}{{> 'systems/daggerheart/templates/actionTypes/damage.hbs' fields=fields.damage.fields.parts.element.fields source=source.damage}}{{/if}} - {{!-- {{#if fields.healing}}{{> 'systems/daggerheart/templates/actionTypes/healing.hbs' fields=fields.healing.fields source=source.healing}}{{/if}} --}} {{#if fields.resource}}{{> 'systems/daggerheart/templates/actionTypes/resource.hbs' fields=fields.resource.fields source=source.resource}}{{/if}} - {{#if fields.documentUUID}}{{> 'systems/daggerheart/templates/actionTypes/uuid.hbs' fields=fields.documentUUID source=source.documentUUID}}{{/if}} + {{#if fields.macro}}{{> 'systems/daggerheart/templates/actionTypes/macro.hbs' fields=fields.macro source=source.macro}}{{/if}} {{#if fields.effects}}{{> 'systems/daggerheart/templates/actionTypes/effect.hbs' fields=fields.effects.element.fields source=source.effects}}{{/if}} {{#if fields.beastform}}{{> 'systems/daggerheart/templates/actionTypes/beastform.hbs' fields=fields.beastform.fields source=source.beastform}}{{/if}} \ No newline at end of file diff --git a/templates/ui/chat/foundryRoll.hbs b/templates/ui/chat/foundryRoll.hbs index 478cc691..a3c55a9e 100644 --- a/templates/ui/chat/foundryRoll.hbs +++ b/templates/ui/chat/foundryRoll.hbs @@ -8,7 +8,7 @@

{{total}}

-
+
\ No newline at end of file