Item ehnance, fixes on actor sheet
This commit is contained in:
@@ -57,6 +57,10 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
|
||||
async _prepareContext() {
|
||||
const context = await super._prepareContext()
|
||||
context.tabs = this.#getTabs()
|
||||
// lineage/class/experience available to all parts (header + identity tab)
|
||||
const doc = this.document
|
||||
context.lineage = doc.itemTypes.lineage?.[0] ?? null
|
||||
context.characterClass = doc.itemTypes["class"]?.[0] ?? null
|
||||
return context
|
||||
}
|
||||
|
||||
@@ -68,8 +72,6 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
|
||||
break
|
||||
case "identity":
|
||||
context.tab = context.tabs.identity
|
||||
context.lineage = doc.itemTypes.lineage?.[0] ?? null
|
||||
context.characterClass = doc.itemTypes["class"]?.[0] ?? null
|
||||
context.abilities = doc.itemTypes.ability
|
||||
context.oaths = doc.itemTypes.oath
|
||||
break
|
||||
@@ -89,14 +91,26 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
|
||||
attribute: attr,
|
||||
label: `OATHHAMMER.Attribute.${attr.charAt(0).toUpperCase()}${attr.slice(1)}`,
|
||||
attrRank: attrRanks[attr],
|
||||
skillData: skillKeys.map(skillKey => ({
|
||||
key: skillKey,
|
||||
label: SYSTEM.SKILLS[skillKey].label,
|
||||
rank: sys.skills[skillKey].rank,
|
||||
name: `system.skills.${skillKey}.rank`,
|
||||
total: attrRanks[attr] + sys.skills[skillKey].rank,
|
||||
field: skillSchemaFields[skillKey].fields.rank,
|
||||
}))
|
||||
skillData: skillKeys.map(skillKey => {
|
||||
const sk = sys.skills[skillKey]
|
||||
return {
|
||||
key: skillKey,
|
||||
label: SYSTEM.SKILLS[skillKey].label,
|
||||
rank: sk.rank,
|
||||
modifier: sk.modifier,
|
||||
colorDice: sk.colorDice,
|
||||
colorDiceType: sk.colorDiceType,
|
||||
rankName: `system.skills.${skillKey}.rank`,
|
||||
modifierName: `system.skills.${skillKey}.modifier`,
|
||||
colorDiceName: `system.skills.${skillKey}.colorDice`,
|
||||
colorDiceTypeName: `system.skills.${skillKey}.colorDiceType`,
|
||||
rankOptions: [0,1,2,3,4].map(v => ({ value: v, label: String(v), selected: v === sk.rank })),
|
||||
total: attrRanks[attr] + sk.rank,
|
||||
// legacy - kept for formInput compatibility
|
||||
name: `system.skills.${skillKey}.rank`,
|
||||
field: skillSchemaFields[skillKey].fields.rank,
|
||||
}
|
||||
})
|
||||
}))
|
||||
break
|
||||
}
|
||||
@@ -125,6 +139,36 @@ export default class OathHammerCharacterSheet extends OathHammerActorSheet {
|
||||
return context
|
||||
}
|
||||
|
||||
/** Auto-fill colorDice count when color type changes */
|
||||
static #COLOR_THRESHOLDS = { white: 4, red: 3, black: 2 }
|
||||
|
||||
_onRender(context, options) {
|
||||
super._onRender?.(context, options)
|
||||
|
||||
// Color dice auto-fill
|
||||
this.element.querySelectorAll('select.color-dice-select').forEach(select => {
|
||||
select.addEventListener('change', event => {
|
||||
const threshold = OathHammerCharacterSheet.#COLOR_THRESHOLDS[event.target.value] ?? 4
|
||||
const countInput = event.target.closest('.skill-color-col')?.querySelector('input[type="number"]')
|
||||
if (countInput) {
|
||||
countInput.value = threshold
|
||||
countInput.dispatchEvent(new Event('change', { bubbles: true }))
|
||||
}
|
||||
const dot = event.target.closest('.skill-color-col')?.querySelector('.color-dice-dot')
|
||||
if (dot) dot.className = `color-dice-dot color-dice-${event.target.value}`
|
||||
})
|
||||
})
|
||||
|
||||
// Equipped checkbox — directly updates the item
|
||||
this.element.querySelectorAll('input.item-equipped-cb').forEach(cb => {
|
||||
cb.addEventListener('change', event => {
|
||||
const itemId = event.target.dataset.itemId
|
||||
const item = this.document.items.get(itemId)
|
||||
if (item) item.update({ 'system.equipped': event.target.checked })
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async _onDrop(event) {
|
||||
if (!this.isEditable) return
|
||||
const data = foundry.applications.ux.TextEditor.implementation.getDragEventData(event)
|
||||
|
||||
@@ -20,9 +20,15 @@ export default class OathHammerCharacter extends foundry.abstract.TypeDataModel
|
||||
fate: attributeField()
|
||||
})
|
||||
|
||||
// Skills: 26 skills each with a rank (0–4). Grit.max = resilience.rank + toughness.rank.
|
||||
// Skills: 26 skills each with a rank (0–4), a bonus/penalty modifier, and color dice.
|
||||
// Total dice = attr rank + skill rank. Modifier = bonus (+) or penalty (-) dice.
|
||||
// Color dice: type (white 4+, red 3+, black 2+) + count of colored dice in the pool.
|
||||
const skillField = () => new fields.SchemaField({
|
||||
rank: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 4 })
|
||||
rank: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 4 }),
|
||||
modifier: new fields.NumberField({ required: true, nullable: false, integer: true, initial: 0 }),
|
||||
colorDiceType: new fields.StringField({ required: true, nullable: false, initial: "white",
|
||||
choices: { white: "OATHHAMMER.ColorDice.White", red: "OATHHAMMER.ColorDice.Red", black: "OATHHAMMER.ColorDice.Black" } }),
|
||||
colorDice: new fields.NumberField({ ...requiredInteger, initial: 4, min: 0 }),
|
||||
})
|
||||
schema.skills = new fields.SchemaField({
|
||||
academics: skillField(),
|
||||
|
||||
Reference in New Issue
Block a user