diff --git a/module/applications/dialogs/_module.mjs b/module/applications/dialogs/_module.mjs index 29a3c876..f9b40f3f 100644 --- a/module/applications/dialogs/_module.mjs +++ b/module/applications/dialogs/_module.mjs @@ -8,4 +8,3 @@ export { default as Downtime } from './downtime.mjs'; export { default as OwnershipSelection } from './ownershipSelection.mjs'; export { default as ResourceDiceDialog } from './resourceDiceDialog.mjs'; export { default as ActionSelectionDialog } from './actionSelectionDialog.mjs'; -export { default as ReactionRollDialog } from './reactionRollDialog.mjs'; diff --git a/module/applications/dialogs/reactionRollDialog.mjs b/module/applications/dialogs/reactionRollDialog.mjs deleted file mode 100644 index 658ab810..00000000 --- a/module/applications/dialogs/reactionRollDialog.mjs +++ /dev/null @@ -1,69 +0,0 @@ - -const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api; - -export default class ReactionRollDialog extends HandlebarsApplicationMixin(ApplicationV2) { - constructor(resolve, reject, actor, trait) { - super({}); - - this.resolve = resolve; - this.reject = reject; - this.actor = actor; - this.trait = trait; - } - - static DEFAULT_OPTIONS = { - tag: 'form', - classes: ['daggerheart', 'views'], - position: { - width: 240, - height: 'auto' - }, - actions: { - // setMarks: this.setMarks, - // useStressReduction: this.useStressReduction, - // takeDamage: this.takeDamage - }, - form: { - handler: this.updateData, - submitOnChange: true, - closeOnSubmit: false - } - }; - - /** @override */ - static PARTS = { - reactionRoll: { - id: 'reactionRoll', - template: 'systems/daggerheart/templates/dialogs/reactionRoll.hbs' - } - }; - - /* -------------------------------------------- */ - - /** @inheritDoc */ - get title() { - return game.i18n.format('DAGGERHEART.APPLICATIONS.ReactionRoll.title', { trait: game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${this.trait}.name`) }); - } - - async _prepareContext(_options) { - const context = await super._prepareContext(_options); - - - return context; - } - - static updateData(event, _, formData) { - const form = foundry.utils.expandObject(formData.object); - this.render(true); - } - - static async reactionRollQuery({ action, token, event, message }) { - return new Promise(async (resolve, reject) => { - // const actor = await fromUuid(actorId); - // if (!actor || !actor?.isOwner) reject(); - action.rollSave(token, event, message).then(result => resolve(result)); - // new ReactionRollDialog(resolve, reject, actor, trait).render({ force: true }); - }); - } - -} \ No newline at end of file diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index f51cd8a8..854a031d 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -108,54 +108,25 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo const targets = event.target.parentElement.querySelectorAll( '.target-section > [data-token] .target-save-container' ); - const promises = [], - actor = await this.getActor(message.system.source.actor), + const actor = await this.getActor(message.system.source.actor), action = this.getAction(actor, message.system.source.item, message.system.source.action); targets.forEach(async el => { const tokenId = el.closest('[data-token]')?.dataset.token, token = game.canvas.tokens.get(tokenId); if(!token.actor) return; - if(game.user === token.actor.owner) { + if(game.user === token.actor.owner) el.dispatchEvent(new PointerEvent('click', { shiftKey: true })); - } else { - // console.log(action, - // token, - // event, - // message) - const reactionRoll = await token.actor.owner.query('reactionRoll', { + else { + token.actor.owner.query('reactionRoll', { actionId: action.uuid, actorId: token.actor.uuid, event, message - }); - if(reactionRoll) { - console.log(reactionRoll) - } - // const armorStackResult = await token.actor.owner.query('armorStack', { - // actorId: token.actor.uuid, - // damage: 3, - // type: ['physical'] - // }, - // { - // timeout: 30000 - // } - // ); + }).then(result => action.updateSaveMessage(result, message, token.id)); } - - // el.dispatchEvent(new PointerEvent('click', { shiftKey: true })); }); } - /* onRollAllSave(event, _message) { - event.stopPropagation(); - const targets = event.target.parentElement.querySelectorAll( - '.target-section > [data-token] .target-save-container' - ); - targets.forEach(el => { - el.dispatchEvent(new PointerEvent('click', { shiftKey: true })); - }); - } */ - async onApplyEffect(event, message) { event.stopPropagation(); const actor = await this.getActor(message.system.source.actor); diff --git a/module/data/action/baseAction.mjs b/module/data/action/baseAction.mjs index 591f1a6c..978d0eeb 100644 --- a/module/data/action/baseAction.mjs +++ b/module/data/action/baseAction.mjs @@ -311,18 +311,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel type: 'reaction' }, data: actor.getRollData() - }) - /* .then(async result => { - if (result) { - const updateMsg = this.updateChatMessage.bind(this, message, target.id, { - result: result.roll.total, - success: result.roll.success - }); - if (game.modules.get('dice-so-nice')?.active) - game.dice3d.waitFor3DAnimationByMessageID(result.message.id).then(()=> updateMsg()); - else updateMsg(); - } - }) */; + }); } updateSaveMessage(result, message, targetId) { @@ -334,6 +323,15 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel game.dice3d.waitFor3DAnimationByMessageID(result.message.id).then(()=> updateMsg()); else updateMsg(); } + + static rollSaveQuery({ actionId, actorId, event, message }) { + return new Promise(async (resolve, reject) => { + const actor = await fromUuid(actorId), + action = await fromUuid(actionId); + if (!actor || !actor?.isOwner) reject(); + action.rollSave(actor, event, message).then(result => resolve(result)); + }); + } /* SAVE */ async updateChatMessage(message, targetId, changes, chain = true) { diff --git a/module/data/actor/base.mjs b/module/data/actor/base.mjs index 1f4060b0..f0db33e9 100644 --- a/module/data/actor/base.mjs +++ b/module/data/actor/base.mjs @@ -5,12 +5,14 @@ const resistanceField = (resistanceLabel, immunityLabel, reductionLabel) => resistance: new foundry.data.fields.BooleanField({ initial: false, label: `${resistanceLabel}.label`, - hint: `${resistanceLabel}.hint` + hint: `${resistanceLabel}.hint`, + isAttributeChoice: true }), immunity: new foundry.data.fields.BooleanField({ initial: false, label: `${immunityLabel}.label`, - hint: `${immunityLabel}.hint` + hint: `${immunityLabel}.hint`, + isAttributeChoice: true }), reduction: new foundry.data.fields.NumberField({ integer: true, diff --git a/module/documents/token.mjs b/module/documents/token.mjs index a8105eb2..b6c47450 100644 --- a/module/documents/token.mjs +++ b/module/documents/token.mjs @@ -52,6 +52,7 @@ export default class DHToken extends TokenDocument { for (const [name, field] of Object.entries(schema.fields)) { const p = _path.concat([name]); if (field instanceof foundry.data.fields.NumberField) attributes.value.push(p); + if (field instanceof foundry.data.fields.BooleanField && field.options.isAttributeChoice) attributes.value.push(p); if (field instanceof foundry.data.fields.StringField) attributes.value.push(p); if (field instanceof foundry.data.fields.ArrayField) attributes.value.push(p); const isSchema = field instanceof foundry.data.fields.SchemaField; diff --git a/module/systemRegistration/socket.mjs b/module/systemRegistration/socket.mjs index 914ea938..0410ec02 100644 --- a/module/systemRegistration/socket.mjs +++ b/module/systemRegistration/socket.mjs @@ -1,5 +1,4 @@ import DamageReductionDialog from '../applications/dialogs/damageReductionDialog.mjs'; -import ReactionRollDialog from '../applications/dialogs/reactionRollDialog.mjs'; export function handleSocketEvent({ action = null, data = {} } = {}) { switch (action) { @@ -74,18 +73,7 @@ export const registerSocketHooks = () => { export const registerUserQueries = () => { CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery; - // CONFIG.queries.reactionRoll = ReactionRollDialog.reactionRollQuery; - CONFIG.queries.reactionRoll = ({ actionId, actorId, event, message }) => { - // console.log('reactionRoll') - return new Promise(async (resolve, reject) => { - // resolve() - const actor = await fromUuid(actorId), - action = await fromUuid(actionId); - if (!actor || !actor?.isOwner) reject(); - action.rollSave(actor, event, message).then(result => resolve(result)); - // new ReactionRollDialog(resolve, reject, actor, trait).render({ force: true }); - }); - } + CONFIG.queries.reactionRoll = game.system.api.models.actions.actionsTypes.base.rollSaveQuery; } export const emitAsGM = async (eventName, callback, update, uuid = null) => {