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,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"),
})
}