mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Feature/416 reaction roll query (#445)
* Create files * before fixing damage roll on main * g * Player query for Roll All Save * Exec Save message as GM for players * Fix DsN bug
This commit is contained in:
parent
2fbbf98f88
commit
2be4ee8857
11 changed files with 91 additions and 38 deletions
|
|
@ -299,9 +299,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',
|
||||
|
|
@ -310,16 +310,28 @@ export default class DHBaseAction extends ActionMixin(foundry.abstract.DataModel
|
|||
difficulty: this.save.difficulty ?? this.actor?.baseSaveDifficulty,
|
||||
type: 'reaction'
|
||||
},
|
||||
data: target.actor.getRollData()
|
||||
})
|
||||
.then(async result => {
|
||||
if (result)
|
||||
this.updateChatMessage(message, target.id, {
|
||||
result: result.roll.total,
|
||||
success: result.roll.success
|
||||
});
|
||||
data: actor.getRollData()
|
||||
});
|
||||
}
|
||||
|
||||
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 ?? 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) {
|
||||
|
|
@ -333,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);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue