#48 Beachte Custom Schadenseingaben #49

Merged
Byroks merged 1 commits from #48-custom-schadens-wurf into develop 2026-11-02 17:23:12 +01:00
+26 -13
View File
@@ -33,17 +33,18 @@ export async function rollSpell(event, target) {
let rollTerm = "@die + @skill"; let rollTerm = "@die + @skill";
let rollFlavor = game.i18n.localize("Midgard6.Zaubern") + ": " + item.name; let rollFlavor = game.i18n.localize("Midgard6.Zaubern") + ": " + item.name;
let roll;
if (dialogResult.spezLevel) { if (dialogResult.spezLevel) {
rollTerm += " + @spezBonus"; rollTerm += " + @spezBonus";
rollFlavor += ": " + dialogResult.spezName; rollFlavor += ": " + dialogResult.spezName;
} }
let rolls;
if (dialogResult.customRoll) { if (dialogResult.customRoll) {
roll = new Roll(dialogResult.customRoll, {}, { title: rollFlavor }); rolls = [await new Roll(dialogResult.customRoll, {}, { title: rollFlavor }).evaluate()];
} else { } else {
roll = new Roll( rolls = [
await new Roll(
rollTerm, rollTerm,
{ {
die: die, die: die,
@@ -51,29 +52,33 @@ export async function rollSpell(event, target) {
spezBonus: dialogResult.spezLevel + 1, spezBonus: dialogResult.spezLevel + 1,
}, },
{ title: rollFlavor }, { title: rollFlavor },
); ).evaluate(),
];
} }
if (item.system.eigenschaften.schaden) { if (dialogResult.customDamageRoll) {
const attackRoll = await roll.evaluate(); rolls.push(
roll = [ await new Roll(
attackRoll, "@die",
{ die: dialogResult.customDamageRoll },
{ title: game.i18n.localize("Midgard6.Schaden") },
).evaluate(),
);
} else if (item.system.eigenschaften.schaden) {
rolls.push(
await new Roll( await new Roll(
"@die", "@die",
{ die: item.system.eigenschaften.schaden }, { die: item.system.eigenschaften.schaden },
{ title: game.i18n.localize("Midgard6.Schaden") }, { title: game.i18n.localize("Midgard6.Schaden") },
).evaluate(), ).evaluate(),
]; );
} else {
// Execute the roll
await roll.evaluate();
} }
// The parsed terms of the roll formula // The parsed terms of the roll formula
console.log("Roll:", roll); // [Die, OperatorTerm, NumericTerm, OperatorTerm, NumericTerm] console.log("Roll:", roll); // [Die, OperatorTerm, NumericTerm, OperatorTerm, NumericTerm]
const chatData = { const chatData = {
rolls: roll, rolls: rolls,
speaker: ChatMessage.getSpeaker(), speaker: ChatMessage.getSpeaker(),
flags: { flags: {
"midgard6-lvd": { "midgard6-lvd": {
@@ -232,11 +237,19 @@ export async function rollWeapon(event, target) {
).evaluate(); ).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( damageRoll = await new Roll(
"@die", "@die",
{ die: weapon.system.schaden }, { die: weapon.system.schaden },
{ title: game.i18n.localize("Midgard6.Schaden") }, { title: game.i18n.localize("Midgard6.Schaden") },
).evaluate(); ).evaluate();
}
// The parsed terms of the roll formula // The parsed terms of the roll formula
const chatData = { const chatData = {