Fixes and enhancements, from issue list

This commit is contained in:
2026-03-27 21:21:17 +01:00
parent f1dda301d7
commit c22c3d713b
25 changed files with 531 additions and 111 deletions

View File

@@ -56,10 +56,11 @@ export function injectFreeRollBar(_chatLog, html) {
rollFree(pool, color, explode5)
})
// Insert between .chat-scroll and .chat-form
// Insert before the chat form — use chatForm.parentElement for AppV2 compatibility
// (in v13 parts are nested inside the app element, not direct children)
const chatForm = html.querySelector(".chat-form")
if (chatForm) {
html.insertBefore(bar, chatForm)
chatForm.parentElement.insertBefore(bar, chatForm)
} else {
html.appendChild(bar)
}

View File

@@ -37,7 +37,7 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
rollInitiative: OathHammerCharacterSheet.#onRollInitiative,
adjustQty: OathHammerCharacterSheet.#onAdjustQty,
adjustCurrency: OathHammerCharacterSheet.#onAdjustCurrency,
adjustStress: OathHammerCharacterSheet.#onAdjustStress,
adjustLuck: OathHammerCharacterSheet.#onAdjustLuck,
clearStress: OathHammerCharacterSheet.#onClearStress,
},
}
@@ -410,6 +410,13 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
await this.document.update({ [field]: Math.max(0, current + delta) })
}
static async #onAdjustLuck(event, target) {
const delta = parseInt(target.dataset.delta, 10)
const current = this.document.system.luck.value ?? 0
// No upper cap — luck can exceed max (e.g. from blessings/bonuses)
await this.document.update({ "system.luck.value": Math.max(0, current + delta) })
}
static async #onAdjustStress(event, target) {
const delta = parseInt(target.dataset.delta, 10)
const current = this.document.system.arcaneStress.value ?? 0

View File

@@ -172,6 +172,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
colorType: attack.system.colorDiceType,
threshold: attack.system.threshold,
bonusOptions,
showExplodeOn5: true,
colorChoices: Object.fromEntries(
Object.entries(SYSTEM.DICE_COLOR_TYPES).map(([k, v]) => [k, game.i18n.localize(v)])
),
@@ -194,6 +195,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
await rollNPCAttackDamage(this.document, attack, {
bonus: parseInt(getValue("bonus")) || 0,
explodeOn5: getValue("explodeOn5") === "true",
visibility: getValue("visibility"),
})
}
@@ -228,6 +230,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
itemName: spell.name, itemImg: spell.img,
dv: spell.system.difficultyValue,
poolOptions, bonusOptions, colorChoices, showColor: true,
showExplodeOn5: true,
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
visibility: game.settings.get("core", "rollMode"),
}
@@ -249,6 +252,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
dicePool: parseInt(getValue("dicePool")) || 3,
bonus: parseInt(getValue("bonus")) || 0,
colorOverride: getValue("colorOverride") || null,
explodeOn5: getValue("explodeOn5") === "true",
visibility: getValue("visibility"),
})
}
@@ -272,6 +276,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
itemName: miracle.name, itemImg: miracle.img,
dv: null, showColor: false,
poolOptions, bonusOptions,
showExplodeOn5: true,
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
visibility: game.settings.get("core", "rollMode"),
}
@@ -292,6 +297,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
await rollNPCMiracle(this.document, miracle, {
dicePool: parseInt(getValue("dicePool")) || 3,
bonus: parseInt(getValue("bonus")) || 0,
explodeOn5: getValue("explodeOn5") === "true",
visibility: getValue("visibility"),
})
}
@@ -323,6 +329,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
threshold,
bonusOptions,
colorChoices,
showExplodeOn5: true,
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
visibility: game.settings.get("core", "rollMode"),
}
@@ -343,6 +350,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
await rollNPCArmor(actor, {
bonus: parseInt(getValue("bonus")) || 0,
colorOverride: getValue("colorOverride") || null,
explodeOn5: getValue("explodeOn5") === "true",
visibility: getValue("visibility"),
})
}
@@ -381,6 +389,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
threshold: item.system.threshold,
bonusOptions,
colorChoices,
showExplodeOn5: true,
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
visibility: game.settings.get("core", "rollMode"),
}
@@ -401,6 +410,7 @@ export default class OathHammerNPCSheet extends OathHammerActorSheet {
await rollNPCSkill(this.document, item, {
bonus: parseInt(getValue("bonus")) || 0,
colorOverride: getValue("colorOverride") || null,
explodeOn5: getValue("explodeOn5") === "true",
visibility: getValue("visibility"),
})
}

View File

@@ -10,9 +10,10 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
window: { contentClasses: ["party-content"] },
actions: {
openMember: OathHammerPartySheet.#onOpenMember,
removeMember: OathHammerPartySheet.#onRemoveMember,
moveMemberUp: OathHammerPartySheet.#onMoveMemberUp,
moveMemberDown: OathHammerPartySheet.#onMoveMemberDown,
removeMember: OathHammerPartySheet.#onRemoveMember,
moveMemberUp: OathHammerPartySheet.#onMoveMemberUp,
moveMemberDown: OathHammerPartySheet.#onMoveMemberDown,
toggleCarriesLight: OathHammerPartySheet.#onToggleCarriesLight,
adjustCurrency: OathHammerPartySheet.#onAdjustCurrency,
adjustQty: OathHammerPartySheet.#onAdjustQty,
},
@@ -53,28 +54,41 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
async _preparePartContext(partId, context) {
const doc = this.document
switch (partId) {
case "main":
case "main": {
const lootItems = doc.items.contents.filter(i => ALLOWED_LOOT_TYPES.has(i.type))
context.currentSlots = lootItems.reduce((sum, i) => {
const slots = i.system.slots ?? 0
const qty = i.system.quantity ?? 1
return sum + slots * qty
}, 0)
break
}
case "members": {
context.tab = context.tabs.members
const refs = doc.system.memberRefs ?? []
context.members = refs.map((id, idx) => {
const actor = game.actors?.get(id)
context.members = refs.map((ref, idx) => {
const actor = game.actors?.get(ref.id)
if (!actor) return null
const sys = actor.system
const classItem = actor.items?.find(i => i.type === "class")
const isNpc = actor.type === "npc"
const classItem = !isNpc ? actor.items?.find(i => i.type === "class") : null
return {
id: actor.id,
name: actor.name,
img: actor.img,
id: actor.id,
name: actor.name,
img: actor.img,
type: actor.type,
idx,
position: idx + 1,
isFirst: idx === 0,
isLast: idx === refs.length - 1,
classLabel: classItem?.name ?? "—",
level: sys.level ?? "—",
grit: sys.grit ? `${sys.grit.value}/${sys.grit.max}` : "—",
position: idx + 1,
isFirst: idx === 0,
isLast: idx === refs.length - 1,
carriesLight: ref.carriesLight ?? false,
classLabel: isNpc
? game.i18n.localize(`OATHHAMMER.NpcSubtype.${sys.subtype === "creature" ? "Creature" : "Npc"}`)
: (classItem?.name ?? "—"),
lineage: !isNpc ? (sys.lineage?.name || "—") : "—",
current: !isNpc ? (sys.experience?.current ?? "—") : "—",
grit: sys.grit ? `${sys.grit.value}/${sys.grit.max}` : "—",
}
}).filter(Boolean)
break
@@ -109,10 +123,10 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
if (data.type === "Actor") {
const actor = await fromUuid(data.uuid)
if (!actor || actor.type !== "character") return
if (!actor || !["character", "npc"].includes(actor.type)) return
const refs = foundry.utils.deepClone(this.document.system.memberRefs ?? [])
if (refs.includes(actor.id)) return
refs.push(actor.id)
if (refs.some(r => r.id === actor.id)) return
refs.push({ id: actor.id, carriesLight: false })
return this.document.update({ "system.memberRefs": refs })
}
@@ -132,7 +146,7 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
static async #onRemoveMember(event, target) {
const id = target.dataset.actorId
const refs = (this.document.system.memberRefs ?? []).filter(r => r !== id)
const refs = (this.document.system.memberRefs ?? []).filter(r => r.id !== id)
await this.document.update({ "system.memberRefs": refs })
}
@@ -152,6 +166,14 @@ export default class OathHammerPartySheet extends OathHammerActorSheet {
await this.document.update({ "system.memberRefs": refs })
}
static async #onToggleCarriesLight(event, target) {
const idx = parseInt(target.dataset.idx, 10)
const refs = foundry.utils.deepClone(this.document.system.memberRefs ?? [])
if (!refs[idx]) return
refs[idx].carriesLight = !refs[idx].carriesLight
await this.document.update({ "system.memberRefs": refs })
}
static async #onAdjustCurrency(event, target) {
const field = target.dataset.field
const delta = parseInt(target.dataset.delta, 10)

View File

@@ -56,6 +56,9 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
context.colorChoices = Object.fromEntries(
Object.entries(SYSTEM.DICE_COLOR_TYPES).map(([k, v]) => [k, game.i18n.localize(v)])
)
context.traitTypeLabels = Object.fromEntries(
Object.entries(SYSTEM.TRAIT_TYPE_CHOICES).map(([k, v]) => [k, v])
)
// Resolve leader actor
const leaderUuid = this.document.system.leaderUuid
if (leaderUuid) {
@@ -75,7 +78,7 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
break
case "skills":
context.tab = context.tabs.skills
context.skills = doc.itemTypes.skillnpc ?? []
context.skills = (doc.itemTypes.skillnpc ?? []).slice().sort((a, b) => a.name.localeCompare(b.name))
break
case "combat":
context.tab = context.tabs.combat
@@ -141,6 +144,9 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
const doc = this.document
const armorDice = doc.system.armorDice
if (!armorDice?.value) return ui.notifications.info("No armor dice to roll.")
const colorType = armorDice.colorDiceType || "white"
const threshold = colorType === "black" ? 2 : colorType === "red" ? 3 : 4
const colorEmoji = colorType === "black" ? "⬛" : colorType === "red" ? "🔴" : "⬜"
const bonusOptions = Array.from({ length: 13 }, (_, i) => {
const v = i - 6
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
@@ -149,9 +155,10 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
"systems/fvtt-oath-hammer/templates/npc-skill-dialog.hbs",
{
skillName: game.i18n.localize("OATHHAMMER.Label.ArmorDice"),
skillImg: doc.img, basePool: armorDice.value, bonusOptions,
skillImg: doc.img, dicePool: armorDice.value,
colorType, colorEmoji, threshold, bonusOptions,
colorChoices: { white: "⬜ White (4+)", red: "🔴 Red (3+)", black: "⬛ Black (2+)" },
selectedColor: armorDice.colorDiceType,
showExplodeOn5: true,
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
visibility: game.settings.get("core", "rollMode")
}
@@ -165,15 +172,19 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
const form = new DOMParser().parseFromString(result, "text/html")
const getValue = n => form.querySelector(`[name="${n}"]`)?.value
await rollNPCArmor(doc, {
bonus: parseInt(getValue("bonus")) || 0,
bonus: parseInt(getValue("bonus")) || 0,
colorOverride: getValue("colorOverride") || null,
visibility: getValue("visibility"),
explodeOn5: getValue("explodeOn5") === "true",
visibility: getValue("visibility"),
})
}
static async #onRollSkillNPC(event, target) {
const skill = this.document.items.get(target.dataset.itemId)
if (!skill) return
const colorType = skill.system.colorDiceType || "white"
const threshold = colorType === "black" ? 2 : colorType === "red" ? 3 : 4
const colorEmoji = colorType === "black" ? "⬛" : colorType === "red" ? "🔴" : "⬜"
const bonusOptions = Array.from({ length: 13 }, (_, i) => {
const v = i - 6
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
@@ -181,9 +192,10 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
const content = await foundry.applications.handlebars.renderTemplate(
"systems/fvtt-oath-hammer/templates/npc-skill-dialog.hbs",
{
skillName: skill.name, skillImg: skill.img, basePool: skill.system.dicePool, bonusOptions,
skillName: skill.name, skillImg: skill.img, dicePool: skill.system.dicePool,
colorType, colorEmoji, threshold, bonusOptions,
colorChoices: { white: "⬜ White (4+)", red: "🔴 Red (3+)", black: "⬛ Black (2+)" },
selectedColor: skill.system.colorDiceType,
showExplodeOn5: true,
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
visibility: game.settings.get("core", "rollMode")
}
@@ -197,9 +209,10 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
const form = new DOMParser().parseFromString(result, "text/html")
const getValue = n => form.querySelector(`[name="${n}"]`)?.value
await rollNPCSkill(this.document, skill, {
bonus: parseInt(getValue("bonus")) || 0,
bonus: parseInt(getValue("bonus")) || 0,
colorOverride: getValue("colorOverride") || null,
visibility: getValue("visibility"),
explodeOn5: getValue("explodeOn5") === "true",
visibility: getValue("visibility"),
})
}
@@ -212,6 +225,9 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
static async #onRollNpcAttack(event, target) {
const attack = this.document.items.get(target.dataset.itemId)
if (!attack) return
const colorType = attack.system.colorDiceType || "white"
const threshold = colorType === "black" ? 2 : colorType === "red" ? 3 : 4
const colorEmoji = colorType === "black" ? "⬛" : colorType === "red" ? "🔴" : "⬜"
const bonusOptions = Array.from({ length: 13 }, (_, i) => {
const v = i - 6
return { value: v, label: v > 0 ? `+${v}` : String(v), selected: v === 0 }
@@ -219,9 +235,11 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
const content = await foundry.applications.handlebars.renderTemplate(
"systems/fvtt-oath-hammer/templates/npc-skill-dialog.hbs",
{
skillName: attack.name, skillImg: attack.img, basePool: attack.system.damageDice, bonusOptions,
skillName: attack.name, skillImg: attack.img,
dicePool: attack.system.damageDice,
colorType, colorEmoji, threshold, bonusOptions,
showExplodeOn5: true,
colorChoices: { white: "⬜ White (4+)", red: "🔴 Red (3+)", black: "⬛ Black (2+)" },
selectedColor: attack.system.colorDiceType,
rollModes: foundry.utils.duplicate(CONFIG.Dice.rollModes),
visibility: game.settings.get("core", "rollMode")
}
@@ -235,9 +253,10 @@ export default class OathHammerRegimentSheet extends OathHammerActorSheet {
const form = new DOMParser().parseFromString(result, "text/html")
const getValue = n => form.querySelector(`[name="${n}"]`)?.value
await rollNPCAttackDamage(this.document, attack, {
bonus: parseInt(getValue("bonus")) || 0,
bonus: parseInt(getValue("bonus")) || 0,
colorOverride: getValue("colorOverride") || null,
visibility: getValue("visibility"),
explodeOn5: getValue("explodeOn5") === "true",
visibility: getValue("visibility"),
})
}

View File

@@ -215,7 +215,8 @@ export const TRAIT_TYPE_CHOICES = {
"class-trait": "OATHHAMMER.TraitType.ClassTrait",
"lineage-trait": "OATHHAMMER.TraitType.LineageTrait",
"npc-trait": "OATHHAMMER.TraitType.NpcTrait",
"creature-trait": "OATHHAMMER.TraitType.CreatureTrait"
"creature-trait": "OATHHAMMER.TraitType.CreatureTrait",
"regiment-trait": "OATHHAMMER.TraitType.RegimentTrait"
}
export const NPC_SUBTYPES = {

View File

@@ -6,9 +6,12 @@ export default class OathHammerParty extends foundry.abstract.TypeDataModel {
schema.notes = new fields.HTMLField({ required: false, nullable: true, initial: "" })
// Ordered list of character actor IDs — position = marching order
// Ordered list of member entries — position = marching order
schema.memberRefs = new fields.ArrayField(
new fields.StringField({ required: true, nullable: false, blank: false })
new fields.SchemaField({
id: new fields.StringField({ required: true, nullable: false, blank: false }),
carriesLight: new fields.BooleanField({ initial: false }),
})
)
schema.treasury = new fields.SchemaField({
@@ -17,8 +20,19 @@ export default class OathHammerParty extends foundry.abstract.TypeDataModel {
cp: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 }),
})
schema.maxSlots = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
return schema
}
static migrateData(source) {
if (Array.isArray(source.memberRefs)) {
source.memberRefs = source.memberRefs.map(r =>
typeof r === "string" ? { id: r, carriesLight: false } : r
)
}
return super.migrateData(source)
}
static LOCALIZATION_PREFIXES = ["OATHHAMMER.Party"]
}

View File

@@ -22,6 +22,7 @@ export default class OathHammerRegiment extends foundry.abstract.TypeDataModel {
schema.movement = new fields.NumberField({ ...requiredInteger, initial: 60, min: 0, max: 500 })
schema.supplyCost = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.recruitmentCost = new fields.NumberField({ ...requiredInteger, initial: 0, min: 0 })
schema.mercenary = new fields.BooleanField({ required: true, initial: false })
schema.leaderUuid = new fields.StringField({ required: false, nullable: true, initial: null })

View File

@@ -915,7 +915,15 @@ export async function rollInitiativeCheck(actor, options = {}) {
})
}
// NPC: Fate rank + initiativeBonus
// NPC: find Leadership skillnpc item, fall back to Fate rank + initiativeBonus
const leadershipSkill = actor.items.find(
i => i.type === "skillnpc" && i.name.toLowerCase() === "leadership"
)
if (leadershipSkill) {
return rollNPCSkill(actor, leadershipSkill, { bonus, visibility })
}
// Fallback: Fate rank + initiativeBonus
const sys = actor.system
const fateRank = sys.attributes?.fate?.rank ?? 1
const initBonus = sys.initiativeBonus ?? 0
@@ -967,7 +975,7 @@ export async function rollInitiativeCheck(actor, options = {}) {
* @param {object} options
*/
export async function rollNPCSkill(actor, skillItem, options = {}) {
const { bonus = 0, colorOverride, visibility } = options
const { bonus = 0, colorOverride, visibility, explodeOn5 = false } = options
const sys = skillItem.system
const colorType = colorOverride || sys.colorDiceType
@@ -976,12 +984,14 @@ export async function rollNPCSkill(actor, skillItem, options = {}) {
const totalDice = Math.max(sys.dicePool + bonus, 1)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, false)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5)
const diceHtml = _diceHtml(diceResults, threshold)
const modLine = bonus !== 0
? `<div class="oh-roll-mods">${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}</div>`
: ""
const explodedCount = diceResults.filter(d => d.exploded).length
const modParts = []
if (bonus !== 0) modParts.push(`${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}`)
if (explodedCount > 0) modParts.push(`💥 ${explodedCount} ${game.i18n.localize("OATHHAMMER.Roll.Exploded")}`)
const modLine = modParts.length ? `<div class="oh-roll-mods">${modParts.join(" · ")}</div>` : ""
const content = `
<div class="oh-roll-card">
@@ -1025,6 +1035,7 @@ export async function rollNPCWeaponAttack(actor, weapon, options = {}) {
const modParts = []
if (bonus !== 0) modParts.push(`${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}`)
if (diceResults.filter(d => d.exploded).length > 0) modParts.push(`💥 ${diceResults.filter(d => d.exploded).length} ${game.i18n.localize("OATHHAMMER.Roll.Exploded")}`)
const modLine = modParts.length ? `<div class="oh-roll-mods">${modParts.join(" · ")}</div>` : ""
const content = `
@@ -1067,6 +1078,7 @@ export async function rollNPCWeaponDamage(actor, weapon, options = {}) {
const modParts = []
if (bonus !== 0) modParts.push(`${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}`)
if (diceResults.filter(d => d.exploded).length > 0) modParts.push(`💥 ${diceResults.filter(d => d.exploded).length} ${game.i18n.localize("OATHHAMMER.Roll.Exploded")}`)
const modLine = modParts.length ? `<div class="oh-roll-mods">${modParts.join(" · ")}</div>` : ""
const content = `
@@ -1098,7 +1110,7 @@ export async function rollNPCWeaponDamage(actor, weapon, options = {}) {
* NPC armor dice roll — rolls actor's armorDice.value dice with armorDice.colorDiceType color.
*/
export async function rollNPCArmor(actor, options = {}) {
const { bonus = 0, colorOverride, visibility } = options
const { bonus = 0, colorOverride, visibility, explodeOn5 = false } = options
const sys = actor.system
const basePool = sys.armorDice?.value ?? 0
@@ -1107,12 +1119,15 @@ export async function rollNPCArmor(actor, options = {}) {
const colorEmoji = colorType === "black" ? "⬛" : colorType === "red" ? "🔴" : "⬜"
const totalDice = Math.max(basePool + bonus, 1)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, false)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5)
const diceHtml = _diceHtml(diceResults, threshold)
const modLine = bonus !== 0
? `<div class="oh-roll-mods">${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}</div>`
: ""
const explodedCount = diceResults.filter(d => d.exploded).length
const modParts = []
if (bonus !== 0) modParts.push(`${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}`)
if (explodeOn5) modParts.push(`💥 ${game.i18n.localize("OATHHAMMER.Dialog.ExplodeOn5")}`)
if (explodedCount > 0) modParts.push(`💥 ${explodedCount} ${game.i18n.localize("OATHHAMMER.Roll.Exploded")}`)
const modLine = modParts.length ? `<div class="oh-roll-mods">${modParts.join(" · ")}</div>` : ""
const label = game.i18n.localize("OATHHAMMER.Label.ArmorDice")
const content = `
@@ -1144,20 +1159,23 @@ export async function rollNPCArmor(actor, options = {}) {
* NPC spell cast — flat dice pool, no arcane stress, posts DV success/failure to chat.
*/
export async function rollNPCSpell(actor, spell, options = {}) {
const { dicePool = 3, bonus = 0, colorOverride, visibility } = options
const { dicePool = 3, bonus = 0, colorOverride, visibility, explodeOn5 = false } = options
const dv = spell.system.difficultyValue ?? 1
const colorType = colorOverride || "white"
const threshold = colorType === "black" ? 2 : colorType === "red" ? 3 : 4
const colorEmoji = colorType === "black" ? "⬛" : colorType === "red" ? "🔴" : "⬜"
const totalDice = Math.max(dicePool + bonus, 1)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, false)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5)
const diceHtml = _diceHtml(diceResults, threshold)
const isSuccess = successes >= dv
const modLine = bonus !== 0
? `<div class="oh-roll-mods">${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}</div>`
: ""
const explodedCount = diceResults.filter(d => d.exploded).length
const modParts = []
if (bonus !== 0) modParts.push(`${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}`)
if (explodeOn5) modParts.push(`💥 ${game.i18n.localize("OATHHAMMER.Dialog.ExplodeOn5")}`)
if (explodedCount > 0) modParts.push(`💥 ${explodedCount} ${game.i18n.localize("OATHHAMMER.Roll.Exploded")}`)
const modLine = modParts.length ? `<div class="oh-roll-mods">${modParts.join(" · ")}</div>` : ""
const resultClass = isSuccess ? "roll-success" : "roll-failure"
const resultLabel = isSuccess
@@ -1193,19 +1211,22 @@ export async function rollNPCSpell(actor, spell, options = {}) {
* NPC miracle invocation — flat dice pool, no blocked tracking, posts DV success/failure to chat.
*/
export async function rollNPCMiracle(actor, miracle, options = {}) {
const { dicePool = 3, bonus = 0, visibility } = options
const { dicePool = 3, bonus = 0, visibility, explodeOn5 = false } = options
const dv = 1
const threshold = 4
const colorEmoji = "⬜"
const totalDice = Math.max(dicePool + bonus, 1)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, false)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5)
const diceHtml = _diceHtml(diceResults, threshold)
const isSuccess = successes >= dv
const modLine = bonus !== 0
? `<div class="oh-roll-mods">${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}</div>`
: ""
const explodedCount = diceResults.filter(d => d.exploded).length
const modParts = []
if (bonus !== 0) modParts.push(`${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}`)
if (explodeOn5) modParts.push(`💥 ${game.i18n.localize("OATHHAMMER.Dialog.ExplodeOn5")}`)
if (explodedCount > 0) modParts.push(`💥 ${explodedCount} ${game.i18n.localize("OATHHAMMER.Roll.Exploded")}`)
const modLine = modParts.length ? `<div class="oh-roll-mods">${modParts.join(" · ")}</div>` : ""
const resultClass = isSuccess ? "roll-success" : "roll-failure"
const resultLabel = isSuccess
@@ -1241,7 +1262,7 @@ export async function rollNPCMiracle(actor, miracle, options = {}) {
* NPC attack damage roll — flat dice pool from the npcattack item, no Might.
*/
export async function rollNPCAttackDamage(actor, attack, options = {}) {
const { bonus = 0, visibility } = options
const { bonus = 0, visibility, explodeOn5 = false } = options
const sys = attack.system
const colorType = sys.colorDiceType || "white"
const threshold = colorType === "black" ? 2 : colorType === "red" ? 3 : 4
@@ -1249,12 +1270,15 @@ export async function rollNPCAttackDamage(actor, attack, options = {}) {
const totalDice = Math.max((sys.damageDice ?? 1) + bonus, 1)
const ap = sys.ap ?? 0
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, false)
const { roll, rolls, successes, diceResults } = await _rollPool(totalDice, threshold, explodeOn5)
const diceHtml = _diceHtml(diceResults, threshold)
const explodedCount = diceResults.filter(d => d.exploded).length
const modParts = []
if (bonus !== 0) modParts.push(`${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}`)
if (ap > 0) modParts.push(`AP ${ap}`)
if (bonus !== 0) modParts.push(`${bonus > 0 ? "+" : ""}${bonus} ${game.i18n.localize("OATHHAMMER.Dialog.Modifier")}`)
if (ap > 0) modParts.push(`AP ${ap}`)
if (explodeOn5) modParts.push(`💥 ${game.i18n.localize("OATHHAMMER.Dialog.ExplodeOn5")}`)
if (explodedCount > 0) modParts.push(`💥 ${explodedCount} ${game.i18n.localize("OATHHAMMER.Roll.Exploded")}`)
const modLine = modParts.length ? `<div class="oh-roll-mods">${modParts.join(" · ")}</div>` : ""
const content = `