UPdate and fixes for roll in combats
Release Creation / build (release) Successful in 43s

This commit is contained in:
2026-05-18 20:26:39 +02:00
parent 7279cd752d
commit 96306623e5
47 changed files with 329 additions and 177 deletions
+42 -12
View File
@@ -339,22 +339,48 @@ Hooks.on("renderChatMessageHTML", (message, html, data) => {
return
}
// Pour les sorts, rouler les dés de dégâts avec option bypass DR
// Pour les sorts, rouler les dés de dégâts avec DR manuelle optionnelle
if (damageType === "spell" && damageFormula) {
const bypassArmor = await foundry.applications.api.DialogV2.confirm({
window: { title: "Spell Damage" },
const manualDR = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.localize("LETHALFANTASY.Combat.spellDRDialogTitle") },
classes: ["lethalfantasy"],
content: "<p>Does this spell's damage bypass armor DR?</p>",
yes: { label: "Yes (ignore armor)", icon: "fa-solid fa-wand-magic-sparkles" },
no: { label: "No (apply armor DR)", icon: "fa-solid fa-shield" }
position: { width: 320 },
content: `<div style="padding:0.5rem 0">
<p style="margin-bottom:0.6rem">${game.i18n.localize("LETHALFANTASY.Combat.spellDRDialogMsg")}</p>
<div style="display:flex;align-items:center;gap:0.5rem">
<label style="font-weight:bold">${game.i18n.localize("LETHALFANTASY.Combat.spellDRLabel")}</label>
<input type="number" name="manualDr" value="0" min="0" style="width:5rem"/>
</div>
</div>`,
buttons: [
{
action: "noDR",
label: game.i18n.localize("LETHALFANTASY.Combat.spellNoDR"),
icon: "fa-solid fa-wand-magic-sparkles",
callback: () => 0
},
{
action: "applyDR",
label: game.i18n.localize("LETHALFANTASY.Combat.spellApplyDR"),
icon: "fa-solid fa-shield",
callback: (event, button, dialog) => Number(dialog.querySelector("[name='manualDr']")?.value) || 0
},
{
action: "cancel",
label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo"),
callback: () => null
}
],
rejectClose: false
})
if (manualDR === null) return
const rollOpts = {
type: "spell-damage",
rollType: "spell-damage",
rollName: damageFormula,
isDamage: true,
rollData: { isDamage: true },
bypassArmor: bypassArmor ?? false,
manualDR: manualDR,
defenderId,
defenderTokenId,
actorId: actor.id,
@@ -922,12 +948,14 @@ Hooks.on("createChatMessage", async (message) => {
const damageTotal = message.rolls[0]?.options?.rollTotal || message.rolls[0]?.total || 0
const weaponName = message.rolls[0]?.options?.rollName || "Unknown Weapon"
const attackerName = message.rolls[0]?.options?.actorName || "Unknown Attacker"
const rollType = message.rolls[0]?.options?.rollType
// Calculer les DR
const bypassArmor = message.rolls[0]?.options?.bypassArmor || false
const armorDR = bypassArmor ? 0 : (defender.computeDamageReduction() || 0)
// Calculer les DR — les sorts utilisent une DR manuelle saisie par l'utilisateur
const isSpellDamage = rollType === "spell-damage"
const manualDR = message.rolls[0]?.options?.manualDR ?? 0
const extraShieldDr = Number(message.rolls[0]?.options?.extraShieldDr) || 0
const totalDR = armorDR + extraShieldDr
const armorDR = isSpellDamage ? manualDR : (defender.computeDamageReduction() || 0)
const totalDR = isSpellDamage ? manualDR : armorDR + extraShieldDr
const finalDamage = Math.max(0, damageTotal - totalDR)
// Prefer the token ID stored in roll options (set at attack time when the exact token is known).
@@ -960,7 +988,9 @@ Hooks.on("createChatMessage", async (message) => {
{
targetName: defender.name,
damage: finalDamage,
drText: bypassArmor ? "Armor DR bypassed (spell)" : (totalDR > 0 ? `Armor DR: ${armorDR}${extraShieldDr > 0 ? ` + Shield DR: ${extraShieldDr}` : ""}` : ""),
drText: isSpellDamage
? (manualDR > 0 ? `Spell DR: ${manualDR}` : "No DR applied")
: (totalDR > 0 ? `Armor DR: ${armorDR}${extraShieldDr > 0 ? ` + Shield DR: ${extraShieldDr}` : ""}` : ""),
weaponName: weaponName,
attackerName: attackerName,
rawDamage: damageTotal