Start combat management

This commit is contained in:
2025-01-12 15:46:36 +01:00
parent 8135a50248
commit 4e70cbfaf8
41 changed files with 896 additions and 543 deletions

View File

@ -131,6 +131,7 @@ export default class LethalFantasyRoll extends Roll {
maxValue = Number(options.rollTarget.value.match(/\d+/)[0])
hasModifier = false
hasChangeDice = true
hasFavor = true
} else {
dice = "1D20"
maxValue = 20
@ -302,7 +303,7 @@ export default class LethalFantasyRoll extends Roll {
}
// Specific pain/poison/contagion case
if (options.rollType === "save" && options.rollTarget.rollKey.includes(["pain", "poison", "contagion"])) {
if (options.rollType === "save" && (options.rollTarget.rollKey === "pain" || options.rollTarget.rollKey === "poison" || options.rollTarget.rollKey === "contagion")) {
hasD30 = false
}
@ -428,8 +429,60 @@ export default class LethalFantasyRoll extends Roll {
return rollBase
}
static async promptInitiative(options = {}) {
const rollModes = Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,
blank: false,
default: "public",
})
if ( SYSTEM.INITIATIVE_DICE_CHOICES_PER_CLASS[options.actorClass] ) {
options.initiativeDiceChoice = SYSTEM.INITIATIVE_DICE_CHOICES_PER_CLASS[options.actorClass]
} else {
options.initiativeDiceChoice = SYSTEM.INITIATIVE_DICE_CHOICES_PER_CLASS["untrained"]
}
let dialogContext = {
actorClass: options.actorClass,
initiativeDiceChoice: options.initiativeDiceChoice,
initiativeDice: "1D20",
maxInit: options.maxInit,
fieldRollMode,
rollModes
}
console.log("CTX", dialogContext)
const content = await renderTemplate("systems/fvtt-lethal-fantasy/templates/roll-initiative-dialog.hbs", dialogContext)
const label = game.i18n.localize("LETHALFANTASY.Label.initiative")
const rollContext = await foundry.applications.api.DialogV2.wait({
window: { title: "Initiative Roll" },
classes: ["lethalfantasy"],
content,
buttons: [
{
label: label,
callback: (event, button, dialog) => {
const output = Array.from(button.form.elements).reduce((obj, input) => {
if (input.name) obj[input.name] = input.value
return obj
}, {})
return output
},
},
],
rejectClose: false // Click on Close button will not launch an error
})
let initRoll = new Roll(`min(${rollContext.initiativeDice}, ${options.maxInit})`, options.data, rollContext)
await initRoll.evaluate()
initRoll.toMessage( {flavor: `Initiative for ${options.actorName}`}, {rollMode: rollContext.visibility} )
}
static async promptRangedDefense(rollTarget) {
const rollModes = Object.fromEntries(Object.entries(CONFIG.Dice.rollModes).map(([key, value]) => [key, game.i18n.localize(value)]))
const fieldRollMode = new foundry.data.fields.StringField({
choices: rollModes,