diff --git a/src/main.mjs b/src/main.mjs index 6fde228..a1cb886 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -883,11 +883,12 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) { const eBE = (await new Roll(item.system.behinderung || "0", { BE: this.document.system.computed.kampf.ruestungen_gesamt.gesamt_behinderung }).evaluate()).total; data.modifikator += eBE; - const talentwert = item.system.talentwert - data.modifikator; + const talentwert = item.system.talentwert - data.modifikator; + const roll_modifier = talentwert < 0 ? -talentwert: 0; - const roll1 = (await new Roll("1d20").evaluate()).total; - const roll2 = (await new Roll("1d20").evaluate()).total; - const roll3 = (await new Roll("1d20").evaluate()).total; + const roll1 = (await new Roll("1d20").evaluate()).total + roll_modifier; + const roll2 = (await new Roll("1d20").evaluate()).total + roll_modifier; + const roll3 = (await new Roll("1d20").evaluate()).total + roll_modifier; const attribute1 = this.document.system.computed.attributes[item.system.attribute1]; const attribute2 = this.document.system.computed.attributes[item.system.attribute2]; @@ -897,7 +898,7 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) { const needed_taw_roll2 = Math.max(roll2 - attribute2, 0); const needed_taw_roll3 = Math.max(roll3 - attribute3, 0); - const leftover_taw = talentwert - needed_taw_roll1 - needed_taw_roll2 - needed_taw_roll3; + const leftover_taw = Math.max(talentwert, 0) - needed_taw_roll1 - needed_taw_roll2 - needed_taw_roll3; const context = { talent: item, @@ -915,7 +916,7 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) { needed_taw_roll2: -needed_taw_roll2, needed_taw_roll3: -needed_taw_roll3, - leftover_taw: leftover_taw, + leftover_taw: Math.min(leftover_taw, item.system.talentwert), }; const message = await ChatMessage.create(