This commit is contained in:
+15
-14
@@ -553,6 +553,17 @@ Hooks.on("preCreateChatMessage", (message) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Build dice breakdown HTML from a reroll result
|
||||||
|
function formatRerollBreakdown(reroll) {
|
||||||
|
const breakdown = (reroll.options?.diceResults || [])
|
||||||
|
.map(r => `<span class="dice-item"><span class="dice-type">${r.dice}</span><span class="dice-separator">→</span><span class="dice-value">${r.value}</span></span>`)
|
||||||
|
.join("")
|
||||||
|
const d30 = reroll.options?.D30message
|
||||||
|
? `<div class="d30-result"><span class="d30-value">D30 → ${reroll.options.D30result || "?"}</span> — ${reroll.options.D30message.description}</div>`
|
||||||
|
: ""
|
||||||
|
return { breakdown, d30 }
|
||||||
|
}
|
||||||
|
|
||||||
// Hook global pour gérer l'offre de Grit à l'attaquant après une défense
|
// Hook global pour gérer l'offre de Grit à l'attaquant après une défense
|
||||||
Hooks.on("createChatMessage", async (message) => {
|
Hooks.on("createChatMessage", async (message) => {
|
||||||
const rollType = message.rolls[0]?.options?.rollType
|
const rollType = message.rolls[0]?.options?.rollType
|
||||||
@@ -572,7 +583,7 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
const {
|
||||||
attackerId,
|
attackerId,
|
||||||
attackRoll,
|
attackRoll,
|
||||||
attackerName,
|
attackerName,
|
||||||
@@ -580,13 +591,13 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
attackWeaponId,
|
attackWeaponId,
|
||||||
attackRollType,
|
attackRollType,
|
||||||
attackRollKey,
|
attackRollKey,
|
||||||
attackD30message,
|
|
||||||
attackRerollContext,
|
attackRerollContext,
|
||||||
attackNaturalRoll,
|
attackNaturalRoll,
|
||||||
damageTier,
|
damageTier,
|
||||||
defenderId,
|
defenderId,
|
||||||
defenderTokenId
|
defenderTokenId
|
||||||
} = attackData
|
} = attackData
|
||||||
|
let { attackD30message } = attackData
|
||||||
let defenseRoll = message.rolls[0]?.options?.rollTotal || message.rolls[0]?.total || 0
|
let defenseRoll = message.rolls[0]?.options?.rollTotal || message.rolls[0]?.total || 0
|
||||||
let defenseD30message = message.rolls[0]?.options?.D30message || null
|
let defenseD30message = message.rolls[0]?.options?.D30message || null
|
||||||
|
|
||||||
@@ -807,12 +818,7 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
if (!reroll) continue
|
if (!reroll) continue
|
||||||
defenseRoll = reroll.options?.rollTotal || reroll.total || oldDefenseRoll
|
defenseRoll = reroll.options?.rollTotal || reroll.total || oldDefenseRoll
|
||||||
// Build dice breakdown HTML from the reroll
|
// Build dice breakdown HTML from the reroll
|
||||||
const rerollBreakdown = (reroll.options?.diceResults || [])
|
const { breakdown: rerollBreakdown, d30: rerollD30 } = formatRerollBreakdown(reroll)
|
||||||
.map(r => `<span class="dice-item"><span class="dice-type">${r.dice}</span><span class="dice-separator">→</span><span class="dice-value">${r.value}</span></span>`)
|
|
||||||
.join("")
|
|
||||||
const rerollD30 = reroll.options?.D30message
|
|
||||||
? `<div class="d30-result"><span class="d30-value">D30 → ${reroll.options.D30result || "?"}</span> — ${reroll.options.D30message.description}</div>`
|
|
||||||
: ""
|
|
||||||
await createReactionMessage(defender,
|
await createReactionMessage(defender,
|
||||||
`<p><strong>${defenderName}</strong> uses Mulligan and re-rolls defense: <strong>${oldDefenseRoll}</strong> → <strong>${defenseRoll}</strong>.</p>
|
`<p><strong>${defenderName}</strong> uses Mulligan and re-rolls defense: <strong>${oldDefenseRoll}</strong> → <strong>${defenseRoll}</strong>.</p>
|
||||||
<div class="dice-breakdown">${rerollBreakdown}</div>${rerollD30}
|
<div class="dice-breakdown">${rerollBreakdown}</div>${rerollD30}
|
||||||
@@ -1020,12 +1026,7 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
if (!reroll) continue
|
if (!reroll) continue
|
||||||
attackRollFinal = reroll.options?.rollTotal || reroll.total || oldAttackRoll
|
attackRollFinal = reroll.options?.rollTotal || reroll.total || oldAttackRoll
|
||||||
// Build dice breakdown HTML from the reroll
|
// Build dice breakdown HTML from the reroll
|
||||||
const rerollBreakdown = (reroll.options?.diceResults || [])
|
const { breakdown: rerollBreakdown, d30: rerollD30 } = formatRerollBreakdown(reroll)
|
||||||
.map(r => `<span class="dice-item"><span class="dice-type">${r.dice}</span><span class="dice-separator">→</span><span class="dice-value">${r.value}</span></span>`)
|
|
||||||
.join("")
|
|
||||||
const rerollD30 = reroll.options?.D30message
|
|
||||||
? `<div class="d30-result"><span class="d30-value">D30 → ${reroll.options.D30result || "?"}</span> — ${reroll.options.D30message.description}</div>`
|
|
||||||
: ""
|
|
||||||
await createReactionMessage(attacker,
|
await createReactionMessage(attacker,
|
||||||
`<p><strong>${attackerName}</strong> uses Mulligan and re-rolls attack: <strong>${oldAttackRoll}</strong> → <strong>${attackRollFinal}</strong>.</p>
|
`<p><strong>${attackerName}</strong> uses Mulligan and re-rolls attack: <strong>${oldAttackRoll}</strong> → <strong>${attackRollFinal}</strong>.</p>
|
||||||
<div class="dice-breakdown">${rerollBreakdown}</div>${rerollD30}
|
<div class="dice-breakdown">${rerollBreakdown}</div>${rerollD30}
|
||||||
|
|||||||
@@ -1505,7 +1505,7 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
if (this.type === "weapon-attack" && this.rollTarget?.weapon) {
|
if (this.type === "weapon-attack" && this.rollTarget?.weapon) {
|
||||||
const weapon = this.rollTarget.weapon
|
const weapon = this.rollTarget.weapon
|
||||||
weaponDamageOptions = {
|
weaponDamageOptions = {
|
||||||
weaponId: weapon.id,
|
weaponId: weapon._id || weapon.id,
|
||||||
weaponName: weapon.name,
|
weaponName: weapon.name,
|
||||||
damageM: weapon.system?.damage?.damageM
|
damageM: weapon.system?.damage?.damageM
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user