Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 05c93f9475 | |||
| bb005ee9fc | |||
| fa5c4cc9ce | |||
| 3b0d4e032e | |||
| 539841c4ff | |||
| ffba37b59e |
@@ -57,7 +57,7 @@ jobs:
|
|||||||
token: ${{ secrets.FOUNDRY_PUBLISH_KEY }}
|
token: ${{ secrets.FOUNDRY_PUBLISH_KEY }}
|
||||||
id: "fvtt-lethal-fantasy"
|
id: "fvtt-lethal-fantasy"
|
||||||
version: ${{github.event.release.tag_name}}
|
version: ${{github.event.release.tag_name}}
|
||||||
manifest: "https://www.uberwald.me/gitea/${{gitea.repository}}/releases/download/${{github.event.release.tag_name}}/system.json"
|
manifest: "https://www.uberwald.me/gitea/uberwald/fvtt-lethal-fantasy/releases/download/latest/system.json"
|
||||||
notes: "https://www.uberwald.me/gitea/public/fvtt-lethal-fantasy/raw/branch/main/changelog.md"
|
notes: "https://www.uberwald.me/gitea/public/fvtt-lethal-fantasy/raw/branch/main/changelog.md"
|
||||||
compatibility-minimum: "14"
|
compatibility-minimum: "14"
|
||||||
compatibility-verified: "14"
|
compatibility-verified: "14"
|
||||||
|
|||||||
+37
-4
@@ -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
|
||||||
@@ -580,15 +591,15 @@ 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
|
||||||
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 +817,18 @@ 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 { breakdown: rerollBreakdown, d30: rerollD30 } = formatRerollBreakdown(reroll)
|
||||||
|
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 +1025,18 @@ 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 { breakdown: rerollBreakdown, d30: rerollD30 } = formatRerollBreakdown(reroll)
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
@@ -616,8 +629,10 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
|
|
||||||
let singleDice = `1D${maxValue}`
|
let singleDice = `1D${maxValue}`
|
||||||
for (let i = 0; i < rollBase.dice.length; i++) {
|
for (let i = 0; i < rollBase.dice.length; i++) {
|
||||||
for (let j = 0; j < rollBase.dice[i].results.length; j++) {
|
const dieResults = rollBase.dice[i].results
|
||||||
let diceResult = rollBase.dice[i].results[j].result
|
const resultCount = dieResults.length
|
||||||
|
for (let j = 0; j < resultCount; j++) {
|
||||||
|
let diceResult = dieResults[j].result
|
||||||
diceResults.push({ dice: `${singleDice.toUpperCase()}`, value: diceResult })
|
diceResults.push({ dice: `${singleDice.toUpperCase()}`, value: diceResult })
|
||||||
diceSum += diceResult
|
diceSum += diceResult
|
||||||
if (hasMaxValue) {
|
if (hasMaxValue) {
|
||||||
@@ -626,6 +641,8 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
diceResult = r.dice[0].results[0].result
|
diceResult = r.dice[0].results[0].result
|
||||||
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
|
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||||
diceSum += (diceResult - 1)
|
diceSum += (diceResult - 1)
|
||||||
|
// Add to DieTerm results so DSN/Foundry display shows explosion dice
|
||||||
|
dieResults.push({ result: diceResult, active: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1214,6 +1231,7 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
diceResult = r.dice[0].results[0].result
|
diceResult = r.dice[0].results[0].result
|
||||||
diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 })
|
diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||||
diceSum += (diceResult - 1)
|
diceSum += (diceResult - 1)
|
||||||
|
rollBase.dice[0].results.push({ result: diceResult, active: true })
|
||||||
}
|
}
|
||||||
if (fullModifier !== 0) {
|
if (fullModifier !== 0) {
|
||||||
diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total })
|
diceResults.push({ dice: `${rollModifier.formula.toUpperCase()}`, value: rollModifier.total })
|
||||||
@@ -1376,6 +1394,7 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
diceResult = r.dice[0].results[0].result
|
diceResult = r.dice[0].results[0].result
|
||||||
diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 })
|
diceResults.push({ dice: `${dice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||||
diceSum += (diceResult - 1)
|
diceSum += (diceResult - 1)
|
||||||
|
rollBase.dice[0].results.push({ result: diceResult, active: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fullModifier !== 0) {
|
if (fullModifier !== 0) {
|
||||||
@@ -1486,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
|
||||||
}
|
}
|
||||||
@@ -1588,7 +1607,8 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
let diceSum = 0
|
let diceSum = 0
|
||||||
for (const term of roll.dice) {
|
for (const term of roll.dice) {
|
||||||
const singleDice = `1D${term.faces}`
|
const singleDice = `1D${term.faces}`
|
||||||
for (const r of term.results) {
|
const termResults = Array.from(term.results)
|
||||||
|
for (const r of termResults) {
|
||||||
let diceResult = r.result
|
let diceResult = r.result
|
||||||
diceResults.push({ dice: singleDice.toUpperCase(), value: diceResult })
|
diceResults.push({ dice: singleDice.toUpperCase(), value: diceResult })
|
||||||
diceSum += diceResult
|
diceSum += diceResult
|
||||||
@@ -1599,6 +1619,7 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
diceResult = xr.dice?.[0]?.results?.[0]?.result ?? (term.faces - 1)
|
diceResult = xr.dice?.[0]?.results?.[0]?.result ?? (term.faces - 1)
|
||||||
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
|
diceResults.push({ dice: `${singleDice.toUpperCase()}-1`, value: diceResult - 1 })
|
||||||
diceSum += (diceResult - 1)
|
diceSum += (diceResult - 1)
|
||||||
|
term.results.push({ result: diceResult, active: 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