Compare commits
2 Commits
3b0d4e032e
...
bb005ee9fc
| Author | SHA1 | Date | |
|---|---|---|---|
| bb005ee9fc | |||
| fa5c4cc9ce |
+36
-4
@@ -572,7 +572,7 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const {
|
let {
|
||||||
attackerId,
|
attackerId,
|
||||||
attackRoll,
|
attackRoll,
|
||||||
attackerName,
|
attackerName,
|
||||||
@@ -588,7 +588,7 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
defenderTokenId
|
defenderTokenId
|
||||||
} = attackData
|
} = 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
|
||||||
const defenseD30message = message.rolls[0]?.options?.D30message || null
|
let defenseD30message = message.rolls[0]?.options?.D30message || null
|
||||||
|
|
||||||
log("Processing defense:", { attackRoll, defenseRoll, attackerId, defenderId })
|
log("Processing defense:", { attackRoll, defenseRoll, attackerId, defenderId })
|
||||||
|
|
||||||
@@ -806,7 +806,23 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
canRerollDefense = false
|
canRerollDefense = false
|
||||||
if (!reroll) continue
|
if (!reroll) continue
|
||||||
defenseRoll = reroll.options?.rollTotal || reroll.total || oldDefenseRoll
|
defenseRoll = reroll.options?.rollTotal || reroll.total || oldDefenseRoll
|
||||||
await createReactionMessage(defender, `<p><strong>${defenderName}</strong> uses Mulligan and re-rolls defense: <strong>${oldDefenseRoll}</strong> → <strong>${defenseRoll}</strong>. Both sides may now react to the new numbers.</p>`)
|
// Build dice breakdown HTML from the reroll
|
||||||
|
const rerollBreakdown = (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 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,
|
||||||
|
`<p><strong>${defenderName}</strong> uses Mulligan and re-rolls defense: <strong>${oldDefenseRoll}</strong> → <strong>${defenseRoll}</strong>.</p>
|
||||||
|
<div class="dice-breakdown">${rerollBreakdown}</div>${rerollD30}
|
||||||
|
<p>Both sides may now react to the new numbers.</p>`
|
||||||
|
)
|
||||||
|
// Apply new D30 result on the restart
|
||||||
|
if (reroll.options?.D30message) {
|
||||||
|
defenseD30message = reroll.options.D30message
|
||||||
|
defenseD30Processed = false
|
||||||
|
}
|
||||||
// Restart the full comparison so both sides can react to the new roll
|
// Restart the full comparison so both sides can react to the new roll
|
||||||
mulliganRestart = true
|
mulliganRestart = true
|
||||||
break
|
break
|
||||||
@@ -1003,7 +1019,23 @@ Hooks.on("createChatMessage", async (message) => {
|
|||||||
canRerollAttack = false
|
canRerollAttack = false
|
||||||
if (!reroll) continue
|
if (!reroll) continue
|
||||||
attackRollFinal = reroll.options?.rollTotal || reroll.total || oldAttackRoll
|
attackRollFinal = reroll.options?.rollTotal || reroll.total || oldAttackRoll
|
||||||
await createReactionMessage(attacker, `<p><strong>${attackerName}</strong> uses Mulligan and re-rolls attack: <strong>${oldAttackRoll}</strong> → <strong>${attackRollFinal}</strong>. Both sides may now react to the new numbers.</p>`)
|
// Build dice breakdown HTML from the reroll
|
||||||
|
const rerollBreakdown = (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 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,
|
||||||
|
`<p><strong>${attackerName}</strong> uses Mulligan and re-rolls attack: <strong>${oldAttackRoll}</strong> → <strong>${attackRollFinal}</strong>.</p>
|
||||||
|
<div class="dice-breakdown">${rerollBreakdown}</div>${rerollD30}
|
||||||
|
<p>Both sides may now react to the new numbers.</p>`
|
||||||
|
)
|
||||||
|
// Apply new D30 result on the restart
|
||||||
|
if (reroll.options?.D30message) {
|
||||||
|
attackD30message = reroll.options.D30message
|
||||||
|
attackD30Processed = false
|
||||||
|
}
|
||||||
// Restart the full comparison so both sides can react to the new roll
|
// Restart the full comparison so both sides can react to the new roll
|
||||||
mulliganRestart = true
|
mulliganRestart = true
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -555,7 +555,13 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
if (rollContext.favor === "favor") {
|
if (rollContext.favor === "favor") {
|
||||||
rollFavor = new this(baseFormula, options.data, rollData)
|
rollFavor = new this(baseFormula, options.data, rollData)
|
||||||
await rollFavor.evaluate()
|
await rollFavor.evaluate()
|
||||||
log("Rolling with favor", rollFavor)
|
log("Favor dice", {
|
||||||
|
rollBaseTotal: rollBase.total,
|
||||||
|
rollFavorTotal: rollFavor.total,
|
||||||
|
rollBaseResults: rollBase.dice.map(d => d.results.map(r => r.result)),
|
||||||
|
rollFavorResults: rollFavor.dice.map(d => d.results.map(r => r.result)),
|
||||||
|
baseFormula
|
||||||
|
})
|
||||||
if (game?.dice3d) {
|
if (game?.dice3d) {
|
||||||
game.dice3d.showForRoll(rollFavor, game.user, true)
|
game.dice3d.showForRoll(rollFavor, game.user, true)
|
||||||
}
|
}
|
||||||
@@ -571,6 +577,13 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
if (rollContext.favor === "disfavor") {
|
if (rollContext.favor === "disfavor") {
|
||||||
rollFavor = new this(baseFormula, options.data, rollData)
|
rollFavor = new this(baseFormula, options.data, rollData)
|
||||||
await rollFavor.evaluate()
|
await rollFavor.evaluate()
|
||||||
|
log("Disfavor dice", {
|
||||||
|
rollBaseTotal: rollBase.total,
|
||||||
|
rollFavorTotal: rollFavor.total,
|
||||||
|
rollBaseResults: rollBase.dice.map(d => d.results.map(r => r.result)),
|
||||||
|
rollFavorResults: rollFavor.dice.map(d => d.results.map(r => r.result)),
|
||||||
|
baseFormula
|
||||||
|
})
|
||||||
if (game?.dice3d) {
|
if (game?.dice3d) {
|
||||||
game.dice3d.showForRoll(rollFavor, game.user, true)
|
game.dice3d.showForRoll(rollFavor, game.user, true)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1128,7 +1128,6 @@ export default class LethalFantasyUtils {
|
|||||||
return await RollClass.prompt({
|
return await RollClass.prompt({
|
||||||
...foundry.utils.duplicate(rerollContext),
|
...foundry.utils.duplicate(rerollContext),
|
||||||
rollContext: foundry.utils.duplicate(rerollContext.rollContext || {}),
|
rollContext: foundry.utils.duplicate(rerollContext.rollContext || {}),
|
||||||
forceNoD30: true,
|
|
||||||
hasTarget: false,
|
hasTarget: false,
|
||||||
target: false
|
target: false
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user