Player query for Roll All Save

This commit is contained in:
Dapoolp 2025-07-28 13:44:31 +02:00
parent 36959156d0
commit 9674b90967
7 changed files with 21 additions and 131 deletions

View file

@ -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';

View file

@ -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 });
});
}
}

View file

@ -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);