Various fixes and changes based on tester feedback

This commit is contained in:
2026-03-17 13:50:32 +01:00
parent 92ba9c3501
commit 000bf348a6
29 changed files with 1450 additions and 192 deletions

View File

@@ -0,0 +1,70 @@
/**
* Armor roll dialog.
*
* Pool = Armor Value (AV) AP penalty + manual bonus (can go to 0, unlike other pools)
* Reinforced trait on the armor → red dice (3+)
* Each success on the roll reduces incoming damage by 1.
*/
export default class OathHammerArmorDialog {
static async prompt(actor, armor) {
const sys = armor.system
const av = sys.armorValue ?? 0
const isReinforced = [...(sys.traits ?? [])].includes("reinforced")
// AP options — entered by the user based on the attacker's weapon
const apOptions = Array.from({ length: 9 }, (_, i) => ({
value: -i,
label: i === 0 ? "0" : `${i}`,
selected: i === 0,
}))
const bonusOptions = Array.from({ length: 7 }, (_, i) => {
const v = i - 3
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
})
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes)
const context = {
actorName: actor.name,
armorName: armor.name,
armorImg: armor.img,
av,
isReinforced,
apOptions,
bonusOptions,
rollModes,
visibility: game.settings.get("core", "rollMode"),
}
const content = await foundry.applications.handlebars.renderTemplate(
"systems/fvtt-oath-hammer/templates/armor-roll-dialog.hbs",
context
)
const result = await foundry.applications.api.DialogV2.wait({
window: { title: game.i18n.format("OATHHAMMER.Dialog.ArmorRollTitle", { armor: armor.name }) },
classes: ["fvtt-oath-hammer"],
content,
rejectClose: false,
buttons: [{
label: game.i18n.localize("OATHHAMMER.Dialog.RollArmor"),
callback: (_ev, btn) => Object.fromEntries(
[...btn.form.elements].filter(e => e.name).map(e => [e.name, e.value])
),
}],
})
if (!result) return null
return {
av,
isReinforced,
apPenalty: parseInt(result.ap) || 0,
bonus: parseInt(result.bonus) || 0,
visibility: result.visibility ?? game.settings.get("core", "rollMode"),
}
}
}