Add initiative rolls

This commit is contained in:
2026-03-18 16:51:10 +01:00
parent 000bf348a6
commit b2befe039e
30 changed files with 512 additions and 144 deletions

View File

@@ -2,7 +2,7 @@
* 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+)
* Reinforced trait on the armor → red dice (3+) by default
* Each success on the roll reduces incoming damage by 1.
*/
export default class OathHammerArmorDialog {
@@ -11,7 +11,8 @@ export default class OathHammerArmorDialog {
const sys = armor.system
const av = sys.armorValue ?? 0
const isReinforced = [...(sys.traits ?? [])].includes("reinforced")
const isReinforced = [...(sys.traits ?? [])].includes("reinforced")
const defaultColor = isReinforced ? "red" : "white"
// AP options — entered by the user based on the attacker's weapon
const apOptions = Array.from({ length: 9 }, (_, i) => ({
@@ -25,6 +26,12 @@ export default class OathHammerArmorDialog {
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
})
const colorOptions = [
{ value: "white", label: "⬜ White (4+)", selected: defaultColor === "white" },
{ value: "red", label: "🔴 Red (3+)", selected: defaultColor === "red" },
{ value: "black", label: "⬛ Black (2+)", selected: defaultColor === "black" },
]
const rollModes = foundry.utils.duplicate(CONFIG.Dice.rollModes)
const context = {
@@ -35,6 +42,7 @@ export default class OathHammerArmorDialog {
isReinforced,
apOptions,
bonusOptions,
colorOptions,
rollModes,
visibility: game.settings.get("core", "rollMode"),
}
@@ -51,9 +59,14 @@ export default class OathHammerArmorDialog {
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])
),
callback: (_ev, btn) => {
const out = {}
for (const el of btn.form.elements) {
if (!el.name) continue
out[el.name] = el.type === "checkbox" ? String(el.checked) : el.value
}
return out
},
}],
})
@@ -62,9 +75,11 @@ export default class OathHammerArmorDialog {
return {
av,
isReinforced,
apPenalty: parseInt(result.ap) || 0,
bonus: parseInt(result.bonus) || 0,
visibility: result.visibility ?? game.settings.get("core", "rollMode"),
colorOverride: result.colorOverride || defaultColor,
apPenalty: parseInt(result.ap) || 0,
bonus: parseInt(result.bonus) || 0,
visibility: result.visibility ?? game.settings.get("core", "rollMode"),
explodeOn5: result.explodeOn5 === "true",
}
}
}