Fix hp < 0 and D30 with D20 bonus roll

This commit is contained in:
2026-06-11 20:48:46 +02:00
parent c20750caa7
commit ea7acf6bf8
29 changed files with 130 additions and 110 deletions
+21 -14
View File
@@ -570,7 +570,7 @@ Hooks.on("createChatMessage", async (message) => {
// ── D30 bonus dice (defense) — resolved before grit/luck/shield ───────
if (defenseD30message && !defenseD30Processed && isPrimaryController(defender)) {
const d30Result = await LethalFantasyUtils.processD30BonusDice(defenseD30message, "defense", null, defender)
const d30Result = await LethalFantasyUtils.processD30BonusDice(defenseD30message, "defense", null, defender, true)
if (d30Result.modifier) {
defenseRoll += d30Result.modifier
if (d30Result.modifier > 0) {
@@ -778,11 +778,12 @@ Hooks.on("createChatMessage", async (message) => {
if (mulliganRestart) continue
// ── D30 bonus dice (attack) — resolved before grit/luck ────────────────
if (attackD30message && !attackD30Processed && isPrimaryController(attacker)) {
const d30Result = await LethalFantasyUtils.processD30BonusDice(attackD30message, "attack", attackNaturalRoll, attacker)
if (attackD30message && !attackD30Processed) {
const canDialog = isPrimaryController(attacker)
const d30Result = await LethalFantasyUtils.processD30BonusDice(attackD30message, "attack", attackNaturalRoll, attacker, canDialog)
if (d30Result.modifier) {
attackRollFinal += d30Result.modifier
if (d30Result.modifier > 0) {
if (d30Result.modifier > 0 && canDialog) {
await createReactionMessage(attacker,
`<p><strong>${attackerName}</strong> gains <strong>+${d30Result.modifier}</strong> from D30 bonus die for attack.</p>`
)
@@ -790,26 +791,32 @@ Hooks.on("createChatMessage", async (message) => {
}
if (d30Result.specialEffect === "auto") {
attackRollFinal = defenseRoll + 1 // auto-hit
await createReactionMessage(attacker,
`<p><strong>${attackerName}</strong> uses <strong>${d30Result.specialName || "Special Strike"}</strong> from D30 — attack automatically hits!</p>`
)
if (canDialog) {
await createReactionMessage(attacker,
`<p><strong>${attackerName}</strong> uses <strong>${d30Result.specialName || "Special Strike"}</strong> from D30 — attack automatically hits!</p>`
)
}
}
if (d30Result.specialEffect === "flag") {
if (d30Result.specialEffect === "flag" && canDialog) {
await createReactionMessage(attacker,
`<p>D30 — <strong>${d30Result.specialName || "Special Effect"}</strong> triggered for ${attackerName}!</p>`
)
}
if (d30Result.specialEffect === "bleed") {
d30Bleed = true
await createReactionMessage(attacker,
`<p>D30 — <strong>Bleeding/Internal Injury</strong> on hit! Damage past DR will cause a bleeding wound.</p>`
)
if (canDialog) {
await createReactionMessage(attacker,
`<p>D30 — <strong>Bleeding/Internal Injury</strong> on hit! Damage past DR will cause a bleeding wound.</p>`
)
}
}
if (d30Result.specialEffect === "damageMultiplier") {
d30DamageMultiplier = d30Result.multiplier
await createReactionMessage(attacker,
`<p>D30 — <strong>x${d30Result.multiplier} damage</strong> before damage reduction!</p>`
)
if (canDialog) {
await createReactionMessage(attacker,
`<p>D30 — <strong>x${d30Result.multiplier} damage</strong> before damage reduction!</p>`
)
}
}
attackD30Processed = true
}