mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +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);
|
this.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async reactionRollQuery({ actorId, trait }) {
|
static async reactionRollQuery({ action, token, event, message }) {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const actor = await fromUuid(actorId);
|
// const actor = await fromUuid(actorId);
|
||||||
if (!actor || !actor?.isOwner) reject();
|
// if (!actor || !actor?.isOwner) reject();
|
||||||
new ReactionRollDialog(resolve, reject, actor, trait).render({ force: true });
|
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) {
|
if (message.system.source.item && message.system.source.action) {
|
||||||
const action = this.getAction(actor, 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;
|
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();
|
event.stopPropagation();
|
||||||
const targets = event.target.parentElement.querySelectorAll(
|
const targets = event.target.parentElement.querySelectorAll(
|
||||||
'.target-section > [data-token] .target-save-container'
|
'.target-section > [data-token] .target-save-container'
|
||||||
|
|
@ -124,7 +168,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
|
||||||
targets.forEach(el => {
|
targets.forEach(el => {
|
||||||
el.dispatchEvent(new PointerEvent('click', { shiftKey: true }));
|
el.dispatchEvent(new PointerEvent('click', { shiftKey: true }));
|
||||||
});
|
});
|
||||||
}
|
} */
|
||||||
|
|
||||||
async onApplyEffect(event, message) {
|
async onApplyEffect(event, message) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
|
||||||
|
|
@ -297,9 +297,9 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
/* EFFECTS */
|
/* EFFECTS */
|
||||||
|
|
||||||
/* SAVE */
|
/* SAVE */
|
||||||
async rollSave(target, event, message) {
|
async rollSave(actor, event, message) {
|
||||||
if (!target?.actor) return;
|
if (!actor) return;
|
||||||
return target.actor
|
return actor
|
||||||
.diceRoll({
|
.diceRoll({
|
||||||
event,
|
event,
|
||||||
title: 'Roll Save',
|
title: 'Roll Save',
|
||||||
|
|
@ -308,15 +308,29 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
difficulty: this.save.difficulty,
|
difficulty: this.save.difficulty,
|
||||||
type: 'reaction'
|
type: 'reaction'
|
||||||
},
|
},
|
||||||
data: target.actor.getRollData()
|
data: actor.getRollData()
|
||||||
})
|
})
|
||||||
.then(async result => {
|
/* .then(async result => {
|
||||||
if (result)
|
if (result) {
|
||||||
this.updateChatMessage(message, target.id, {
|
const updateMsg = this.updateChatMessage.bind(this, message, target.id, {
|
||||||
result: result.roll.total,
|
result: result.roll.total,
|
||||||
success: result.roll.success
|
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 */
|
/* SAVE */
|
||||||
|
|
||||||
|
|
@ -331,7 +345,7 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
||||||
if (chain) {
|
if (chain) {
|
||||||
if (message.system.source.message)
|
if (message.system.source.message)
|
||||||
this.updateChatMessage(ui.chat.collection.get(message.system.source.message), targetId, changes, false);
|
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 => {
|
relatedChatMessages.forEach(c => {
|
||||||
this.updateChatMessage(c, targetId, changes, false);
|
this.updateChatMessage(c, targetId, changes, false);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,11 @@ export default class DhpActor extends Actor {
|
||||||
actorId: this.uuid,
|
actorId: this.uuid,
|
||||||
damage: hpDamage.value,
|
damage: hpDamage.value,
|
||||||
type: [...hpDamage.damageTypes]
|
type: [...hpDamage.damageTypes]
|
||||||
});
|
},
|
||||||
|
{
|
||||||
|
timeout: 30000
|
||||||
|
}
|
||||||
|
);
|
||||||
if (armorStackResult) {
|
if (armorStackResult) {
|
||||||
const { modifiedDamage, armorSpent, stressSpent } = armorStackResult;
|
const { modifiedDamage, armorSpent, stressSpent } = armorStackResult;
|
||||||
updates.find(u => u.key === 'hitPoints').value = modifiedDamage;
|
updates.find(u => u.key === 'hitPoints').value = modifiedDamage;
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,18 @@ export const registerSocketHooks = () => {
|
||||||
|
|
||||||
export const registerUserQueries = () => {
|
export const registerUserQueries = () => {
|
||||||
CONFIG.queries.armorStack = DamageReductionDialog.armorStackQuery;
|
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) => {
|
export const emitAsGM = async (eventName, callback, update, uuid = null) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue