mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 07:36:26 +01:00
g
This commit is contained in:
parent
506faacd45
commit
9e771059f1
5 changed files with 95 additions and 21 deletions
|
|
@ -57,11 +57,12 @@ export default class ReactionRollDialog extends HandlebarsApplicationMixin(Appli
|
|||
this.render(true);
|
||||
}
|
||||
|
||||
static async reactionRollQuery({ actorId, trait }) {
|
||||
static async reactionRollQuery({ action, token, event, message }) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const actor = await fromUuid(actorId);
|
||||
if (!actor || !actor?.isOwner) reject();
|
||||
new ReactionRollDialog(resolve, reject, actor, trait).render({ force: true });
|
||||
// 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 });
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,11 +112,55 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
if (message.system.source.item && message.system.source.action) {
|
||||
const action = this.getAction(actor, message.system.source.item, message.system.source.action);
|
||||
if (!action || !action?.hasSave) return;
|
||||
action.rollSave(token, event, message);
|
||||
action.rollSave(token.actor, event, message).then(result => action.updateSaveMessage(result, message, token.id));
|
||||
}
|
||||
}
|
||||
|
||||
onRollAllSave(event, _message) {
|
||||
async onRollAllSave(event, message) {
|
||||
event.stopPropagation();
|
||||
if(!game.user.isGM) return;
|
||||
const targets = event.target.parentElement.querySelectorAll(
|
||||
'.target-section > [data-token] .target-save-container'
|
||||
);
|
||||
const promises = [],
|
||||
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) {
|
||||
el.dispatchEvent(new PointerEvent('click', { shiftKey: true }));
|
||||
} else {
|
||||
// console.log(action,
|
||||
// token,
|
||||
// event,
|
||||
// message)
|
||||
const reactionRoll = await 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
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
// 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'
|
||||
|
|
@ -124,7 +168,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
|||
targets.forEach(el => {
|
||||
el.dispatchEvent(new PointerEvent('click', { shiftKey: true }));
|
||||
});
|
||||
}
|
||||
} */
|
||||
|
||||
async onApplyEffect(event, message) {
|
||||
event.stopPropagation();
|
||||
|
|
|
|||
|
|
@ -297,9 +297,9 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
/* EFFECTS */
|
||||
|
||||
/* SAVE */
|
||||
async rollSave(target, event, message) {
|
||||
if (!target?.actor) return;
|
||||
return target.actor
|
||||
async rollSave(actor, event, message) {
|
||||
if (!actor) return;
|
||||
return actor
|
||||
.diceRoll({
|
||||
event,
|
||||
title: 'Roll Save',
|
||||
|
|
@ -308,15 +308,29 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
difficulty: this.save.difficulty,
|
||||
type: 'reaction'
|
||||
},
|
||||
data: target.actor.getRollData()
|
||||
data: actor.getRollData()
|
||||
})
|
||||
.then(async result => {
|
||||
if (result)
|
||||
this.updateChatMessage(message, target.id, {
|
||||
/* .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) {
|
||||
const updateMsg = this.updateChatMessage.bind(this, message, targetId, {
|
||||
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();
|
||||
}
|
||||
/* SAVE */
|
||||
|
||||
|
|
@ -331,7 +345,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
if (chain) {
|
||||
if (message.system.source.message)
|
||||
this.updateChatMessage(ui.chat.collection.get(message.system.source.message), targetId, changes, false);
|
||||
const relatedChatMessages = ui.chat.collection.filter(c => c.system.source.message === message._id);
|
||||
const relatedChatMessages = ui.chat.collection.filter(c => c.system.source?.message === message._id);
|
||||
relatedChatMessages.forEach(c => {
|
||||
this.updateChatMessage(c, targetId, changes, false);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -443,10 +443,14 @@ export default class DhpActor extends Actor {
|
|||
this.#canReduceDamage(hpDamage.value, hpDamage.damageTypes)
|
||||
) {
|
||||
const armorStackResult = await this.owner.query('armorStack', {
|
||||
actorId: this.uuid,
|
||||
damage: hpDamage.value,
|
||||
type: [...hpDamage.damageTypes]
|
||||
});
|
||||
actorId: this.uuid,
|
||||
damage: hpDamage.value,
|
||||
type: [...hpDamage.damageTypes]
|
||||
},
|
||||
{
|
||||
timeout: 30000
|
||||
}
|
||||
);
|
||||
if (armorStackResult) {
|
||||
const { modifiedDamage, armorSpent, stressSpent } = armorStackResult;
|
||||
updates.find(u => u.key === 'hitPoints').value = modifiedDamage;
|
||||
|
|
|
|||
|
|
@ -74,7 +74,18 @@ export const registerSocketHooks = () => {
|
|||
|
||||
export const registerUserQueries = () => {
|
||||
CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery;
|
||||
CONFIG.queries.reactionRoll = ReactionRollDialog.reactionRollQuery;
|
||||
// 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 });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const emitAsGM = async (eventName, callback, update, uuid = null) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue