Fix weapon sheet

This commit is contained in:
2026-03-08 17:27:59 +01:00
parent 31318317a7
commit e8d84615c5
15 changed files with 572 additions and 47 deletions

View File

@@ -22,6 +22,8 @@ export default class OathHammerArmorSheet extends OathHammerItemSheet {
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
const enrich = (v) => foundry.applications.ux.TextEditor.implementation.enrichHTML(v ?? "", { async: true })
context.enrichedMagicEffect = await enrich(this.document.system.magicEffect)
return context
}
}

View File

@@ -1,4 +1,5 @@
const { HandlebarsApplicationMixin } = foundry.applications.api
import { ARMOR_TYPE_CHOICES, WEAPON_PROFICIENCY_GROUPS } from "../../config/system.mjs"
export default class OathHammerItemSheet extends HandlebarsApplicationMixin(foundry.applications.sheets.ItemSheetV2) {
static SHEET_MODES = { EDIT: 0, PLAY: 1 }
@@ -68,6 +69,9 @@ export default class OathHammerItemSheet extends HandlebarsApplicationMixin(foun
context.apChoices = Object.fromEntries(
Array.from({ length: 7 }, (_, i) => [i, String(i)])
)
// Class proficiency choices (for class-sheet checkboxes)
context.armorTypeChoices = ARMOR_TYPE_CHOICES
context.weaponGroupChoices = WEAPON_PROFICIENCY_GROUPS
return context
}

View File

@@ -27,4 +27,16 @@ export default class OathHammerClassSheet extends OathHammerItemSheet {
)
return context
}
/** @override — collect checkbox sets explicitly so unchecking all works */
_prepareSubmitData(event, form, formData) {
const data = super._prepareSubmitData(event, form, formData)
data["system.armorProficiency"] = Array.from(
form.querySelectorAll('input[name="system.armorProficiency"]:checked')
).map(el => el.value)
data["system.weaponProficiency"] = Array.from(
form.querySelectorAll('input[name="system.weaponProficiency"]:checked')
).map(el => el.value)
return data
}
}

View File

@@ -22,6 +22,8 @@ export default class OathHammerMagicItemSheet extends OathHammerItemSheet {
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
const enrich = (v) => foundry.applications.ux.TextEditor.implementation.enrichHTML(v ?? "", { async: true })
context.enrichedEffect = await enrich(this.document.system.effect)
return context
}
}

View File

@@ -22,6 +22,8 @@ export default class OathHammerWeaponSheet extends OathHammerItemSheet {
/** @override */
async _prepareContext() {
const context = await super._prepareContext()
const enrich = (v) => foundry.applications.ux.TextEditor.implementation.enrichHTML(v ?? "", { async: true })
context.enrichedMagicEffect = await enrich(this.document.system.magicEffect)
return context
}
}