Enhancements as per issue tracking sheet
This commit is contained in:
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user