mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 05:01:08 +01:00
Added button render to renderJournalEntryPageProseMirrorSheet and renderHandlebarsApplication
This commit is contained in:
parent
4501edcf4a
commit
bdba416f21
1 changed files with 48 additions and 34 deletions
|
|
@ -129,42 +129,56 @@ Hooks.on(socketEvent.GMUpdate, async (action, uuid, update) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on('renderChatMessageHTML', (message, element) => {
|
const renderDualityButton = async event => {
|
||||||
element.querySelectorAll('.duality-roll-button').forEach(element =>
|
const button = event.currentTarget;
|
||||||
element.addEventListener('click', async event => {
|
const attributeValue = button.dataset.attribute?.toLowerCase();
|
||||||
let target = getCommandTarget();
|
|
||||||
if (!target) return;
|
|
||||||
|
|
||||||
const button = event.currentTarget;
|
const target = getCommandTarget();
|
||||||
const rollModifier = button.dataset.attribute
|
if (!target) return;
|
||||||
? target.system.attributes[button.dataset.attribute].data.value
|
|
||||||
: null;
|
|
||||||
const { roll, hope, fear, advantage, disadvantage, modifiers } = await target.diceRoll({
|
|
||||||
title: button.dataset.label,
|
|
||||||
value: rollModifier
|
|
||||||
});
|
|
||||||
const cls = getDocumentClass('ChatMessage');
|
|
||||||
const msgData = {
|
|
||||||
type: 'dualityRoll',
|
|
||||||
sound: CONFIG.sounds.dice,
|
|
||||||
system: {
|
|
||||||
title: button.dataset.label,
|
|
||||||
origin: target.id,
|
|
||||||
roll: roll._formula,
|
|
||||||
modifiers: modifiers,
|
|
||||||
hope: hope,
|
|
||||||
fear: fear,
|
|
||||||
advantage: advantage,
|
|
||||||
disadvantage: disadvantage
|
|
||||||
},
|
|
||||||
user: game.user.id,
|
|
||||||
content: 'systems/daggerheart/templates/chat/duality-roll.hbs',
|
|
||||||
rolls: [roll]
|
|
||||||
};
|
|
||||||
|
|
||||||
await cls.create(msgData);
|
const rollModifier = attributeValue ? target.system.attributes[attributeValue].data.value : null;
|
||||||
})
|
const { roll, hope, fear, advantage, disadvantage, modifiers } = await target.diceRoll({
|
||||||
);
|
title: button.dataset.label,
|
||||||
|
value: rollModifier
|
||||||
|
});
|
||||||
|
const cls = getDocumentClass('ChatMessage');
|
||||||
|
const msgData = {
|
||||||
|
type: 'dualityRoll',
|
||||||
|
sound: CONFIG.sounds.dice,
|
||||||
|
system: {
|
||||||
|
title: button.dataset.label,
|
||||||
|
origin: target.id,
|
||||||
|
roll: roll._formula,
|
||||||
|
modifiers: modifiers,
|
||||||
|
hope: hope,
|
||||||
|
fear: fear,
|
||||||
|
advantage: advantage,
|
||||||
|
disadvantage: disadvantage
|
||||||
|
},
|
||||||
|
user: game.user.id,
|
||||||
|
content: 'systems/daggerheart/templates/chat/duality-roll.hbs',
|
||||||
|
rolls: [roll]
|
||||||
|
};
|
||||||
|
|
||||||
|
await cls.create(msgData);
|
||||||
|
};
|
||||||
|
|
||||||
|
Hooks.on('renderChatMessageHTML', (_, element) => {
|
||||||
|
element
|
||||||
|
.querySelectorAll('.duality-roll-button')
|
||||||
|
.forEach(element => element.addEventListener('click', renderDualityButton));
|
||||||
|
});
|
||||||
|
|
||||||
|
Hooks.on('renderJournalEntryPageProseMirrorSheet', (_, element) => {
|
||||||
|
element
|
||||||
|
.querySelectorAll('.duality-roll-button')
|
||||||
|
.forEach(element => element.addEventListener('click', renderDualityButton));
|
||||||
|
});
|
||||||
|
|
||||||
|
Hooks.on('renderHandlebarsApplication', (_, element) => {
|
||||||
|
element
|
||||||
|
.querySelectorAll('.duality-roll-button')
|
||||||
|
.forEach(element => element.addEventListener('click', renderDualityButton));
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on('chatMessage', (_, message) => {
|
Hooks.on('chatMessage', (_, message) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue