mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Embedding Duality Rolls (#52)
* Added DualityRoll direct rolls in chat * Added button render to renderJournalEntryPageProseMirrorSheet and renderHandlebarsApplication * Hope and Fear dice totals are now properly added together * Added Colorful/Normal DualityRoll color settings
This commit is contained in:
parent
cf51153432
commit
d1a0a9ab24
19 changed files with 1192 additions and 1264 deletions
36
module/enrichers/DualityRollEnricher.mjs
Normal file
36
module/enrichers/DualityRollEnricher.mjs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import { abilities } from '../config/actorConfig.mjs';
|
||||
import { rollCommandToJSON } from '../helpers/utils.mjs';
|
||||
|
||||
export function dualityRollEnricher(match, _options) {
|
||||
const roll = rollCommandToJSON(match[1]);
|
||||
if (!roll) return match[0];
|
||||
|
||||
return getDualityMessage(roll);
|
||||
}
|
||||
|
||||
export function getDualityMessage(roll) {
|
||||
const attributeLabel =
|
||||
roll.attribute && abilities[roll.attribute]
|
||||
? game.i18n.format('DAGGERHEART.General.Check', {
|
||||
check: game.i18n.localize(abilities[roll.attribute].label)
|
||||
})
|
||||
: null;
|
||||
const label = attributeLabel ?? game.i18n.localize('DAGGERHEART.General.Duality');
|
||||
|
||||
const dualityElement = document.createElement('span');
|
||||
dualityElement.innerHTML = `
|
||||
<button class="duality-roll-button"
|
||||
data-label="${label}"
|
||||
data-hope="${roll.hope ?? 'd12'}"
|
||||
data-fear="${roll.fear ?? 'd12'}"
|
||||
${roll.attribute && abilities[roll.attribute] ? `data-attribute="${roll.attribute}"` : ''}
|
||||
${roll.advantage ? 'data-advantage="true"' : ''}
|
||||
${roll.disadvantage ? 'data-disadvantage="true"' : ''}
|
||||
>
|
||||
<i class="fa-solid fa-circle-half-stroke"></i>
|
||||
${label}
|
||||
</button>
|
||||
`;
|
||||
|
||||
return dualityElement;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue