mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Fix/857 generic roll buttons (#866)
* Action Macro working again * Remove buttons from generic roll for non-gm
This commit is contained in:
parent
e90355b08b
commit
f62e51c4f6
11 changed files with 27 additions and 69 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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';
|
||||
|
|
|
|||
7
module/data/fields/action/macroField.mjs
Normal file
7
module/data/fields/action/macroField.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
const fields = foundry.data.fields;
|
||||
|
||||
export default class MacroField extends fields.DocumentUUIDField {
|
||||
constructor(context = {}) {
|
||||
super({ type: "Macro" }, context);
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue