Fix triple damage issue
This commit is contained in:
+2
-1
@@ -936,7 +936,8 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
d30Bleed: d30Bleed ? "true" : "",
|
d30Bleed: d30Bleed ? "true" : "",
|
||||||
d30DamageMultiplier: d30DamageMultiplier,
|
d30DamageMultiplier: d30DamageMultiplier,
|
||||||
d30DrMultiplier: d30DrMultiplier,
|
d30DrMultiplier: d30DrMultiplier,
|
||||||
damageTier: damageTier || "standard"
|
damageTier: damageTier || "standard",
|
||||||
|
attackD30message
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
console.log("Skipping message creation", { attackerHandledBonus, defenderHandledBonus })
|
console.log("Skipping message creation", { attackerHandledBonus, defenderHandledBonus })
|
||||||
|
|||||||
+17
-5
@@ -1074,6 +1074,18 @@ export default class LethalFantasyUtils {
|
|||||||
/* -------------------------------------------- */
|
/* -------------------------------------------- */
|
||||||
static async compareAttackDefense(data) {
|
static async compareAttackDefense(data) {
|
||||||
console.log("compareAttackDefense called with:", data)
|
console.log("compareAttackDefense called with:", data)
|
||||||
|
|
||||||
|
// Compute D30 effects from the attack D30 message directly.
|
||||||
|
// This is more reliable than depending on the caller-provided values, which are
|
||||||
|
// computed per-client and may differ between clients due to cross-client processing order.
|
||||||
|
const d30DamageMultiplier = data.attackD30message?.type === "damage_multiplier"
|
||||||
|
? data.attackD30message.multiplier
|
||||||
|
: (data.d30DamageMultiplier || 1)
|
||||||
|
const d30Bleed = data.attackD30message?.type === "combo"
|
||||||
|
? (data.attackD30message.effects?.some(e => e.type === "bleed" || e.type === "internal_injury") ? "true" : "")
|
||||||
|
: data.attackD30message?.type === "bleed" ? "true" : (data.d30Bleed || "")
|
||||||
|
const d30DrMultiplier = data.d30DrMultiplier || 1
|
||||||
|
|
||||||
const outcome = data.outcome || (data.attackRoll > data.defenseRoll ? "hit" : "miss")
|
const outcome = data.outcome || (data.attackRoll > data.defenseRoll ? "hit" : "miss")
|
||||||
const isAttackWin = outcome !== "miss"
|
const isAttackWin = outcome !== "miss"
|
||||||
console.log("isAttackWin:", isAttackWin, "attackRoll:", data.attackRoll, "defenseRoll:", data.defenseRoll)
|
console.log("isAttackWin:", isAttackWin, "attackRoll:", data.attackRoll, "defenseRoll:", data.defenseRoll)
|
||||||
@@ -1085,7 +1097,7 @@ export default class LethalFantasyUtils {
|
|||||||
if (data.attackRollType === "weapon-attack") {
|
if (data.attackRollType === "weapon-attack") {
|
||||||
damageButton = `
|
damageButton = `
|
||||||
<div class="attack-result-damage single-btn">
|
<div class="attack-result-damage single-btn">
|
||||||
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-weapon-id="${data.attackWeaponId}" data-damage-type="medium" data-d30-bleed="${data.d30Bleed || ""}" data-d30-damage-mult="${data.d30DamageMultiplier || 1}" data-d30-dr-mult="${data.d30DrMultiplier || 1}">
|
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-weapon-id="${data.attackWeaponId}" data-damage-type="medium" data-d30-bleed="${d30Bleed}" data-d30-damage-mult="${d30DamageMultiplier}" data-d30-dr-mult="${d30DrMultiplier}">
|
||||||
<i class="fa-solid fa-dice-d20"></i> Damage
|
<i class="fa-solid fa-dice-d20"></i> Damage
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -1093,7 +1105,7 @@ export default class LethalFantasyUtils {
|
|||||||
} else if (data.attackRollType === "monster-attack") {
|
} else if (data.attackRollType === "monster-attack") {
|
||||||
damageButton = `
|
damageButton = `
|
||||||
<div class="attack-result-damage single-btn">
|
<div class="attack-result-damage single-btn">
|
||||||
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-attack-key="${data.attackRollKey}" data-damage-type="monster" data-d30-bleed="${data.d30Bleed || ""}" data-d30-damage-mult="${data.d30DamageMultiplier || 1}" data-d30-dr-mult="${data.d30DrMultiplier || 1}">
|
<button class="roll-damage-btn" data-attacker-id="${data.attackerId}" data-defender-id="${data.defenderId}" data-defender-token-id="${data.defenderTokenId || ""}" data-extra-shield-dr="${data.shieldDamageReduction || 0}" data-attack-key="${data.attackRollKey}" data-damage-type="monster" data-d30-bleed="${d30Bleed}" data-d30-damage-mult="${d30DamageMultiplier}" data-d30-dr-mult="${d30DrMultiplier}">
|
||||||
<i class="fa-solid fa-burst"></i> Damage
|
<i class="fa-solid fa-burst"></i> Damage
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -1118,9 +1130,9 @@ export default class LethalFantasyUtils {
|
|||||||
data-defender-token-id="${data.defenderTokenId || ""}"
|
data-defender-token-id="${data.defenderTokenId || ""}"
|
||||||
data-damage-type="spell"
|
data-damage-type="spell"
|
||||||
data-damage-formula="${escapedFormula}"
|
data-damage-formula="${escapedFormula}"
|
||||||
data-d30-bleed="${data.d30Bleed || ""}"
|
data-d30-bleed="${d30Bleed}"
|
||||||
data-d30-damage-mult="${data.d30DamageMultiplier || 1}"
|
data-d30-damage-mult="${d30DamageMultiplier}"
|
||||||
data-d30-dr-mult="${data.d30DrMultiplier || 1}">
|
data-d30-dr-mult="${d30DrMultiplier}">
|
||||||
<i class="fa-solid fa-wand-magic-sparkles"></i> ${t.label} (${escapedFormula})
|
<i class="fa-solid fa-wand-magic-sparkles"></i> ${t.label} (${escapedFormula})
|
||||||
</button>`
|
</button>`
|
||||||
}).join("")
|
}).join("")
|
||||||
|
|||||||
Reference in New Issue
Block a user