mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Fixed duality roll buttons
This commit is contained in:
parent
75ee44af52
commit
01aa1b4bdd
3 changed files with 11 additions and 10 deletions
|
|
@ -135,7 +135,7 @@ Hooks.on(socketEvent.GMUpdate, async (action, uuid, update) => {
|
|||
|
||||
const renderDualityButton = async event => {
|
||||
const button = event.currentTarget,
|
||||
attributeValue = button.dataset.attribute?.toLowerCase(),
|
||||
traitValue = button.dataset.trait?.toLowerCase(),
|
||||
target = getCommandTarget();
|
||||
if (!target) return;
|
||||
|
||||
|
|
@ -143,7 +143,8 @@ const renderDualityButton = async event => {
|
|||
event: event,
|
||||
title: button.dataset.label,
|
||||
roll: {
|
||||
modifier: attributeValue ? target.system.attributes[attributeValue].data.value : null,
|
||||
modifier: traitValue ? target.system.traits[traitValue].value : null,
|
||||
label: button.dataset.label,
|
||||
type: button.dataset.actionType ?? null // Need check
|
||||
},
|
||||
chatMessage: {
|
||||
|
|
@ -239,7 +240,7 @@ Hooks.on('chatMessage', (_, message) => {
|
|||
|
||||
const hopeAndFearRoll = `1${rollCommand.hope ?? 'd12'}+1${rollCommand.fear ?? 'd12'}`;
|
||||
const advantageRoll = `${rollCommand.advantage && !rollCommand.disadvantage ? '+d6' : rollCommand.disadvantage && !rollCommand.advantage ? '-d6' : ''}`;
|
||||
const attributeRoll = `${trait?.data?.value ? `${trait.data.value > 0 ? `+${trait.data.value}` : `${trait.data.value}`}` : ''}`;
|
||||
const attributeRoll = `${trait?.value ? `${trait.value > 0 ? `+${trait.value}` : `${trait.value}`}` : ''}`;
|
||||
const roll = await Roll.create(`${hopeAndFearRoll}${advantageRoll}${attributeRoll}`).evaluate();
|
||||
|
||||
setDiceSoNiceForDualityRoll(
|
||||
|
|
|
|||
|
|
@ -271,8 +271,8 @@ export default class DhpActor extends Actor {
|
|||
}
|
||||
|
||||
formatRollModifier(roll) {
|
||||
const modifier = roll.modifier ? Number.parseInt(roll.modifier) : null;
|
||||
return roll.modifier !== null
|
||||
const modifier = roll.modifier !== null ? Number.parseInt(roll.modifier) : null;
|
||||
return modifier !== null
|
||||
? [
|
||||
{
|
||||
value: modifier,
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ export function dualityRollEnricher(match, _options) {
|
|||
}
|
||||
|
||||
export function getDualityMessage(roll) {
|
||||
const attributeLabel =
|
||||
roll.attribute && abilities[roll.attribute]
|
||||
const traitLabel =
|
||||
roll.trait && abilities[roll.trait]
|
||||
? game.i18n.format('DAGGERHEART.General.Check', {
|
||||
check: game.i18n.localize(abilities[roll.attribute].label)
|
||||
check: game.i18n.localize(abilities[roll.trait].label)
|
||||
})
|
||||
: null;
|
||||
const label = attributeLabel ?? game.i18n.localize('DAGGERHEART.General.Duality');
|
||||
const label = traitLabel ?? game.i18n.localize('DAGGERHEART.General.Duality');
|
||||
|
||||
const dualityElement = document.createElement('span');
|
||||
dualityElement.innerHTML = `
|
||||
|
|
@ -23,7 +23,7 @@ export function getDualityMessage(roll) {
|
|||
data-label="${label}"
|
||||
data-hope="${roll.hope ?? 'd12'}"
|
||||
data-fear="${roll.fear ?? 'd12'}"
|
||||
${roll.attribute && abilities[roll.attribute] ? `data-attribute="${roll.attribute}"` : ''}
|
||||
${roll.trait && abilities[roll.trait] ? `data-trait="${roll.trait}"` : ''}
|
||||
${roll.advantage ? 'data-advantage="true"' : ''}
|
||||
${roll.disadvantage ? 'data-disadvantage="true"' : ''}
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue