diff --git a/src/sheets/components/roll-actions.mjs b/src/sheets/components/roll-actions.mjs index b5404f5..e1e0004 100644 --- a/src/sheets/components/roll-actions.mjs +++ b/src/sheets/components/roll-actions.mjs @@ -33,47 +33,52 @@ export async function rollSpell(event, target) { let rollTerm = "@die + @skill"; let rollFlavor = game.i18n.localize("Midgard6.Zaubern") + ": " + item.name; - let roll; if (dialogResult.spezLevel) { rollTerm += " + @spezBonus"; rollFlavor += ": " + dialogResult.spezName; } + let rolls; if (dialogResult.customRoll) { - roll = new Roll(dialogResult.customRoll, {}, { title: rollFlavor }); + rolls = [await new Roll(dialogResult.customRoll, {}, { title: rollFlavor }).evaluate()]; } else { - roll = new Roll( - rollTerm, - { - die: die, - skill: skillValue, - spezBonus: dialogResult.spezLevel + 1, - }, - { title: rollFlavor }, - ); + rolls = [ + await new Roll( + rollTerm, + { + die: die, + skill: skillValue, + spezBonus: dialogResult.spezLevel + 1, + }, + { title: rollFlavor }, + ).evaluate(), + ]; } - if (item.system.eigenschaften.schaden) { - const attackRoll = await roll.evaluate(); - roll = [ - attackRoll, + if (dialogResult.customDamageRoll) { + rolls.push( + await new Roll( + "@die", + { die: dialogResult.customDamageRoll }, + { title: game.i18n.localize("Midgard6.Schaden") }, + ).evaluate(), + ); + } else if (item.system.eigenschaften.schaden) { + rolls.push( await new Roll( "@die", { die: item.system.eigenschaften.schaden }, { title: game.i18n.localize("Midgard6.Schaden") }, ).evaluate(), - ]; - } else { - // Execute the roll - await roll.evaluate(); + ); } // The parsed terms of the roll formula console.log("Roll:", roll); // [Die, OperatorTerm, NumericTerm, OperatorTerm, NumericTerm] const chatData = { - rolls: roll, + rolls: rolls, speaker: ChatMessage.getSpeaker(), flags: { "midgard6-lvd": { @@ -232,11 +237,19 @@ export async function rollWeapon(event, target) { ).evaluate(); } - damageRoll = await new Roll( - "@die", - { die: weapon.system.schaden }, - { title: game.i18n.localize("Midgard6.Schaden") }, - ).evaluate(); + if (dialogResult.customDamageRoll) { + damageRoll = await new Roll( + dialogResult.customDamageRoll, + {}, + { title: game.i18n.localize("Midgard6.Schaden") }, + ).evaluate(); + } else if (weapon.system.schaden) { + damageRoll = await new Roll( + "@die", + { die: weapon.system.schaden }, + { title: game.i18n.localize("Midgard6.Schaden") }, + ).evaluate(); + } // The parsed terms of the roll formula const chatData = {