Enhancements as per issue tracking sheet

This commit is contained in:
2026-03-19 15:39:25 +01:00
parent b2befe039e
commit b67d85c6be
22 changed files with 588 additions and 55 deletions

View File

@@ -108,6 +108,9 @@ export default class OathHammerActorSheet extends HandlebarsApplicationMixin(fou
_onDragOver(event) {}
async _onDropItem(item) {
// Ignore drops of items already owned by this actor (internal drag = no-op)
if (item.parent?.id === this.document.id) return
const itemData = item.toObject()
// Class is unique: replace any existing item of the same type
if (item.type === "class") {

View File

@@ -35,6 +35,8 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
rollArmorSave: OathHammerCharacterSheet.#onRollArmorSave,
resetMiracleBlocked: OathHammerCharacterSheet.#onResetMiracleBlocked,
rollInitiative: OathHammerCharacterSheet.#onRollInitiative,
adjustQty: OathHammerCharacterSheet.#onAdjustQty,
adjustCurrency: OathHammerCharacterSheet.#onAdjustCurrency,
},
}
@@ -109,6 +111,8 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
id: o.id, uuid: o.uuid, img: o.img, name: o.name, system: o.system,
_typeLabel: typeEntry ? game.i18n.localize(typeEntry.label) : o.system.oathType,
_violated: o.system.violated,
_boonText: _stripHtml(o.system.boon, 80),
_baneText: _stripHtml(o.system.bane, 80),
_descTooltip: _stripHtml(parts.join(" "))
}
})
@@ -184,9 +188,12 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
}
})
context.ammunition = doc.itemTypes.ammunition
// Slot tracking: max = 10 + (Might rank × 2); used = sum of all items' slots
// Slot tracking: max = 10 + (Might rank × 2); used = sum of all items' slots × quantity
context.slotsMax = 10 + (doc.system.attributes.might.rank * 2)
context.slotsUsed = doc.items.reduce((sum, item) => sum + (item.system.slots ?? 0), 0)
context.slotsUsed = doc.items.reduce((sum, item) => {
const qty = item.system.quantity ?? 1
return sum + (item.system.slots ?? 0) * Math.max(qty, 1)
}, 0)
context.slotsOver = context.slotsUsed > context.slotsMax
// Show current initiative score if actor is in an active combat
const combatant = game.combat?.combatants.find(c => c.actor?.id === doc.id)
@@ -214,7 +221,10 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
_descTooltip: _stripHtml(m.system.description)
}))
context.slotsMax = 10 + (doc.system.attributes.might.rank * 2)
context.slotsUsed = doc.items.reduce((sum, item) => sum + (item.system.slots ?? 0), 0)
context.slotsUsed = doc.items.reduce((sum, item) => {
const qty = item.system.quantity ?? 1
return sum + (item.system.slots ?? 0) * Math.max(qty, 1)
}, 0)
context.slotsOver = context.slotsUsed > context.slotsMax
break
case "notes":
@@ -376,6 +386,24 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
await rollInitiativeCheck(actor)
}
}
static async #onAdjustQty(event, target) {
const itemId = target.dataset.itemId
const delta = parseInt(target.dataset.delta, 10)
if (!itemId || isNaN(delta)) return
const item = this.document.items.get(itemId)
if (!item) return
const current = item.system.quantity ?? 0
await item.update({ "system.quantity": Math.max(0, current + delta) })
}
static async #onAdjustCurrency(event, target) {
const field = target.dataset.field
const delta = parseInt(target.dataset.delta, 10)
if (!field || isNaN(delta)) return
const current = foundry.utils.getProperty(this.document, field) ?? 0
await this.document.update({ [field]: Math.max(0, current + delta) })
}
}
/** Strip HTML tags and collapse whitespace for use in data-tooltip attributes. */