diff --git a/module/applications/chatMessage.mjs b/module/applications/chatMessage.mjs index f16f6fc5..48935fa1 100644 --- a/module/applications/chatMessage.mjs +++ b/module/applications/chatMessage.mjs @@ -1,7 +1,7 @@ export default class DhpChatMesssage extends ChatMessage { async renderHTML() { if(this.type === 'dualityRoll' || this.type === 'adversaryRoll' || this.type === 'abilityUse'){ - this.content = await renderTemplate(this.content, this.system); + this.content = await foundry.applications.handlebars.renderTemplate(this.content, this.system); } return super.renderHTML(); diff --git a/module/applications/sheets/pc.mjs b/module/applications/sheets/pc.mjs index cfe3038b..0e440be6 100644 --- a/module/applications/sheets/pc.mjs +++ b/module/applications/sheets/pc.mjs @@ -320,11 +320,11 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { this.render(); } - static async rollAttribute(_, event){ - const { roll, hope, fear, advantage, disadvantage, modifiers } = await this.document.dualityRoll({ title: 'Attribute Bonus', value: event.currentTarget.dataset.value }, event.shiftKey); + static async rollAttribute(event, target) { + const { roll, hope, fear, advantage, disadvantage, modifiers } = await this.document.dualityRoll({ title: 'Attribute Bonus', value: event.target.dataset.value }, event.shiftKey); const cls = getDocumentClass("ChatMessage"); - const msg = new cls({ + const msgData = { type: 'dualityRoll', system: { roll: roll._formula, @@ -337,9 +337,9 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) { user: game.user.id, content: "systems/daggerheart/templates/chat/duality-roll.hbs", rolls: [roll] - }); + }; - await cls.create(msg.toObject()); + await cls.create(msgData); } static async toggleMarks(_, button){ diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index e599a061..6cbb2b0d 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -87,9 +87,10 @@ export default class DhpActor extends Actor { async dualityRoll(modifier, shiftKey, bonusDamage=[]){ let hopeDice = 'd12', fearDice = 'd12', advantageDice = null, disadvantageDice = null, bonusDamageString = ""; + const modifiers = [ { - value: Number.parseInt(modifier.value), + value: modifier.value ? Number.parseInt(modifier.value) : 0, label: modifier.value >= 0 ? `+${modifier.value}` : `-${modifier.value}`, title: modifier.title, } @@ -104,11 +105,11 @@ export default class DhpActor extends Actor { bonusDamageString = result.bonusDamage; const automateHope = await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.Hope); + if(automateHope && result.hopeUsed){ await this.update({ "system.resources.hope.value": this.system.resources.hope.value - result.hopeUsed }); } } - const roll = new Roll(`1${hopeDice} + 1${fearDice}${advantageDice ? ` + 1${advantageDice}` : disadvantageDice ? ` - 1${disadvantageDice}` : ''} ${modifiers.map(x => `+ ${x.value}`).join(' ')}`); let rollResult = await roll.evaluate(); rollResult.dice[0].options.appearance = { diff --git a/templates/sheets/parts/effects.hbs b/templates/sheets/parts/effects.hbs index e429851d..13c50355 100644 --- a/templates/sheets/parts/effects.hbs +++ b/templates/sheets/parts/effects.hbs @@ -55,12 +55,12 @@ {{#if (eq effect.valueType ../config.valueTypes.select.id)}}