mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 15:39:02 +01:00
Player query for Roll All Save
This commit is contained in:
parent
36959156d0
commit
9674b90967
7 changed files with 21 additions and 131 deletions
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue