Add luck option after roll, attributes above 6, fix miracle icon and grit bonus
All checks were successful
Release Creation / build (release) Successful in 1m36s
All checks were successful
Release Creation / build (release) Successful in 1m36s
This commit is contained in:
52
module/applications/luck-roll-dialog.mjs
Normal file
52
module/applications/luck-roll-dialog.mjs
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Dialog for spending Luck Points after a roll result is known.
|
||||
* Called from the "🍀 Luck" button on chat cards.
|
||||
*/
|
||||
export default class OathHammerLuckRollDialog {
|
||||
|
||||
/**
|
||||
* Prompt the actor's owner to spend luck points after seeing a roll result.
|
||||
* @param {Actor} actor
|
||||
* @returns {Promise<{luckSpend: number, luckIsHuman: boolean}|null>}
|
||||
*/
|
||||
static async prompt(actor) {
|
||||
const actorSys = actor.system
|
||||
const availableLuck = actorSys.luck?.value ?? 0
|
||||
if (availableLuck <= 0) {
|
||||
ui.notifications.warn(game.i18n.localize("OATHHAMMER.Roll.NoLuckLeft"))
|
||||
return null
|
||||
}
|
||||
|
||||
const isHuman = (actorSys.lineage?.name ?? "").toLowerCase() === "human"
|
||||
const luckDicePerPoint = isHuman ? 3 : 2
|
||||
|
||||
const luckOptions = Array.from({ length: availableLuck + 1 }, (_, i) => ({
|
||||
value: i,
|
||||
label: i === 0 ? "0" : `${i} LP (+${i * luckDicePerPoint}d)`,
|
||||
selected: i === 1,
|
||||
}))
|
||||
|
||||
const content = await foundry.applications.handlebars.renderTemplate(
|
||||
"systems/fvtt-oath-hammer/templates/luck-roll-dialog.hbs",
|
||||
{ availableLuck, isHuman, luckOptions }
|
||||
)
|
||||
|
||||
const result = await foundry.applications.api.DialogV2.wait({
|
||||
window: { title: game.i18n.format("OATHHAMMER.Dialog.LuckPostRollTitle", { name: actor.name }) },
|
||||
classes: ["fvtt-oath-hammer"],
|
||||
content,
|
||||
rejectClose: false,
|
||||
buttons: [{
|
||||
label: game.i18n.localize("OATHHAMMER.Dialog.LuckPostRollConfirm"),
|
||||
callback: (_ev, btn) => {
|
||||
const spend = parseInt(btn.form.elements.luckSpend?.value) || 0
|
||||
const isH = btn.form.elements.luckIsHuman?.checked ?? false
|
||||
return { luckSpend: spend, luckIsHuman: isH }
|
||||
},
|
||||
}],
|
||||
})
|
||||
|
||||
if (!result || result.luckSpend <= 0) return null
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ export default class OathHammerItemSheet extends HandlebarsApplicationMixin(foun
|
||||
)
|
||||
// Weapon-specific numeric selects
|
||||
context.damageModChoices = Object.fromEntries(
|
||||
Array.from({ length: 10 }, (_, i) => [i - 4, i - 4 >= 0 ? `+${i - 4}` : String(i - 4)])
|
||||
Array.from({ length: 20 }, (_, i) => [i - 4, i - 4 >= 0 ? `+${i - 4}` : String(i - 4)])
|
||||
)
|
||||
context.apChoices = Object.fromEntries(
|
||||
Array.from({ length: 7 }, (_, i) => [i, String(i)])
|
||||
|
||||
@@ -348,7 +348,7 @@ export default class OathHammerWeaponDialog {
|
||||
selected: i === defaultSV,
|
||||
}))
|
||||
|
||||
const damageBonusOptions = Array.from({ length: 9 }, (_, i) => {
|
||||
const damageBonusOptions = Array.from({ length: 20 }, (_, i) => {
|
||||
const v = i - 4
|
||||
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user