Other fixes for damage buttons from chat
This commit is contained in:
@@ -22,6 +22,7 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
divinityPointsMinus: LethalFantasyCharacterSheet.#onDivinityPointsMinus,
|
||||
aetherPointsPlus: LethalFantasyCharacterSheet.#onAetherPointsPlus,
|
||||
aetherPointsMinus: LethalFantasyCharacterSheet.#onAetherPointsMinus,
|
||||
rollSpellDamage: LethalFantasyCharacterSheet.#onRollSpellDamage,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -70,10 +71,10 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
biography: { id: "biography", group: "sheet", icon: "fa-solid fa-book", label: "LETHALFANTASY.Label.biography" },
|
||||
}
|
||||
if (this.actor.system.biodata.magicUser) {
|
||||
tabs.spells = { id: "spells", group: "sheet", icon: "fa-sharp-duotone fa-solid fa-wand-magic-sparkles", label: "LETHALFANTASY.Label.spells" }
|
||||
tabs.spells = { id: "spells", group: "sheet", icon: "fa-solid fa-wand-magic-sparkles", label: "LETHALFANTASY.Label.spells" }
|
||||
}
|
||||
if (this.actor.system.biodata.clericUser) {
|
||||
tabs.miracles = { id: "miracles", group: "sheet", icon: "fa-sharp-duotone fa-solid fa-hands-praying", label: "LETHALFANTASY.Label.miracles" }
|
||||
tabs.miracles = { id: "miracles", group: "sheet", icon: "fa-solid fa-hands-praying", label: "LETHALFANTASY.Label.miracles" }
|
||||
}
|
||||
for (const v of Object.values(tabs)) {
|
||||
v.active = this.tabGroups[v.group] === v.id
|
||||
@@ -219,6 +220,79 @@ export default class LethalFantasyCharacterSheet extends LethalFantasyActorSheet
|
||||
this.actor.update({ "system.aetherPoints.value": points })
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles spell damage roll from the spell sheet tab.
|
||||
* Shows a DR dialog then rolls the appropriate damage formula.
|
||||
* @param {PointerEvent} event
|
||||
* @param {HTMLElement} target
|
||||
*/
|
||||
static async #onRollSpellDamage(event, target) {
|
||||
if (this.isEditMode) return
|
||||
const itemId = target.dataset.itemId
|
||||
const tier = target.dataset.damageTier
|
||||
const spell = this.actor.items.get(itemId)
|
||||
if (!spell) return
|
||||
|
||||
const formulaMap = {
|
||||
standard: spell.system.damageDice,
|
||||
overpowered: spell.system.damageDiceOverpowered,
|
||||
overpowered2: spell.system.damageDiceOverpowered2,
|
||||
}
|
||||
const formula = formulaMap[tier]
|
||||
if (!formula) return
|
||||
|
||||
const manualDR = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.localize("LETHALFANTASY.Combat.spellDRDialogTitle") },
|
||||
classes: ["lethalfantasy"],
|
||||
position: { width: 320 },
|
||||
content: `<div style="padding:0.5rem 0">
|
||||
<p style="margin-bottom:0.6rem">${game.i18n.localize("LETHALFANTASY.Combat.spellDRDialogMsg")}</p>
|
||||
<div style="display:flex;align-items:center;gap:0.5rem">
|
||||
<label style="font-weight:bold">${game.i18n.localize("LETHALFANTASY.Combat.spellDRLabel")}</label>
|
||||
<input type="number" name="manualDr" value="0" min="0" style="width:5rem"/>
|
||||
</div>
|
||||
</div>`,
|
||||
buttons: [
|
||||
{
|
||||
action: "noDR",
|
||||
label: game.i18n.localize("LETHALFANTASY.Combat.spellNoDR"),
|
||||
icon: "fa-solid fa-wand-magic-sparkles",
|
||||
callback: () => 0
|
||||
},
|
||||
{
|
||||
action: "applyDR",
|
||||
label: game.i18n.localize("LETHALFANTASY.Combat.spellApplyDR"),
|
||||
icon: "fa-solid fa-shield",
|
||||
callback: (event, button) => Number(button.form?.elements?.manualDr?.value) || 0
|
||||
},
|
||||
{
|
||||
action: "cancel",
|
||||
label: game.i18n.localize("LETHALFANTASY.Combat.proceedNo"),
|
||||
callback: () => null
|
||||
}
|
||||
],
|
||||
rejectClose: false
|
||||
})
|
||||
if (manualDR === null) return
|
||||
|
||||
const rollOpts = {
|
||||
type: "spell-damage",
|
||||
rollType: "spell-damage",
|
||||
rollName: `${spell.name} — ${formula}`,
|
||||
isDamage: true,
|
||||
rollData: { isDamage: true },
|
||||
manualDR,
|
||||
actorId: this.actor.id,
|
||||
actorName: this.actor.name,
|
||||
actorImage: this.actor.img
|
||||
}
|
||||
const roll = new LethalFantasyRoll(formula, {}, rollOpts)
|
||||
await roll.evaluate()
|
||||
roll.options.rollTotal = roll.total
|
||||
if (game?.dice3d) await game.dice3d.showForRoll(roll, game.user, true)
|
||||
await roll.toMessage()
|
||||
}
|
||||
|
||||
static #onCreateEquipment(event, target) {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user