Various updates

This commit is contained in:
2025-01-09 22:26:37 +01:00
parent d0284d2b84
commit 949755b680
36 changed files with 288 additions and 14 deletions

View File

@ -92,6 +92,10 @@ export default class LethalFantasyRoll extends Roll {
return this.options.D30result
}
get badResult() {
return this.options.badResult
}
/**
* Prompt the user with a dialog to configure and execute a roll.
*
@ -117,6 +121,7 @@ export default class LethalFantasyRoll extends Roll {
let hasModifier = true
let hasChangeDice = false
let hasD30 = false
let hasFavor = false
if (options.rollType === "challenge" || options.rollType === "save") {
options.rollName = options.rollTarget.rollKey
@ -137,6 +142,7 @@ export default class LethalFantasyRoll extends Roll {
baseFormula = "D100"
maxValue = 100
hasModifier = true
hasFavor = true
hasChangeDice = false
options.rollTarget.value = options.rollTarget.system.skillTotal
@ -148,6 +154,7 @@ export default class LethalFantasyRoll extends Roll {
maxValue = 20
hasModifier = true
hasChangeDice = false
hasFavor = true
if (options.rollType === "weapon-attack") {
options.rollTarget.value = options.rollTarget.combat.attackModifier + options.rollTarget.weaponSkillModifier
options.rollTarget.charModifier = options.rollTarget.combat.attackModifier
@ -209,6 +216,7 @@ export default class LethalFantasyRoll extends Roll {
const choiceModifier = SYSTEM.CHOICE_MODIFIERS
const choiceDice = SYSTEM.CHOICE_DICE
const choiceFavor = SYSTEM.FAVOR_CHOICES
let modifier = "+0"
let targetName
@ -219,17 +227,20 @@ export default class LethalFantasyRoll extends Roll {
rollName: options.rollName,
rollModes,
hasModifier,
hasFavor,
hasChangeDice,
baseValue: options.rollTarget.value,
changeDice: `${dice}`,
fieldRollMode,
choiceModifier,
choiceDice,
choiceFavor,
baseFormula,
dice,
hasTarget: options.hasTarget,
modifier,
saveSpell: false,
favor : "none",
targetName
}
console.log("dialogContext", dialogContext)
@ -322,12 +333,46 @@ export default class LethalFantasyRoll extends Roll {
*/
if (Hooks.call("fvtt-lethal-fantasy.preRoll", options, rollData) === false) return
const rollBase = new this(baseFormula, options.data, rollData)
let rollBase = new this(baseFormula, options.data, rollData)
const rollModifier = new Roll(modifierFormula, options.data, rollData)
rollModifier.evaluate()
await rollBase.evaluate()
let rollFavor
let badResult
if (rollContext.favor === "favor") {
rollFavor = new this(baseFormula, options.data, rollData)
await rollFavor.evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(rollFavor, game.user, true)
}
if (rollFavor.result > rollBase.result) {
badResult = rollBase.result
rollBase = rollFavor
} else {
badResult = rollFavor.result
}
}
if (rollContext.favor === "disfavor") {
rollFavor = new this(baseFormula, options.data, rollData)
await rollFavor.evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(rollFavor, game.user, true)
}
if (rollFavor.result < rollBase.result) {
badResult = rollBase.result
rollBase = rollFavor
} else {
badResult = rollFavor.result
}
}
if (hasD30) {
let rollD30 = await new Roll("1D30").evaluate()
if (game?.dice3d) {
await game.dice3d.showForRoll(rollFavor, game.user, true)
}
options.D30result = rollD30.total
}
@ -367,6 +412,7 @@ export default class LethalFantasyRoll extends Roll {
rollBase.options.rollTarget = options.rollTarget
rollBase.options.titleFormula = titleFormula
rollBase.options.D30result = options.D30result
rollBase.options.badResult = badResult
/**
* A hook event that fires after the roll has been made.
@ -589,6 +635,7 @@ export default class LethalFantasyRoll extends Roll {
targetName: this.targetName,
targetArmor: this.targetArmor,
D30result: this.D30result,
badResult: this.badResult,
isPrivate: isPrivate
}
cardData.cssClass = cardData.css.join(" ")