Nouvelles corrections sur la fiche

This commit is contained in:
2026-03-06 11:31:04 +01:00
parent 65dc626380
commit b9db8eb2fc
4 changed files with 42 additions and 8 deletions
+22 -2
View File
@@ -18,7 +18,8 @@ export default class AwECharacterSheet extends AwEActorSheet {
createKit: AwECharacterSheet.#onCreateKit,
createEquipment: AwECharacterSheet.#onCreateEquipment,
flowPointsPlus: AwECharacterSheet.#onFlowPointsPlus,
flowPointsMinus: AwECharacterSheet.#onFlowPointsMinus
flowPointsMinus: AwECharacterSheet.#onFlowPointsMinus,
rollField: AwECharacterSheet.#onRollField
}
}
@@ -83,7 +84,13 @@ export default class AwECharacterSheet extends AwEActorSheet {
break
case "biography":
context.tab = context.tabs.biography
context.fields = doc.itemTypes.field
context.fields = doc.itemTypes.field.map(item => ({
...item,
keyAttrLabel: game.i18n.localize(SYSTEM.ATTRIBUTES[item.system.keyAttribute]?.label ?? item.system.keyAttribute),
keyAttr2Label: item.system.keyAttribute2
? game.i18n.localize(SYSTEM.ATTRIBUTES[item.system.keyAttribute2]?.label ?? item.system.keyAttribute2)
: null
}))
context.archetypes = doc.itemTypes.archetype
context.backgrounds = doc.itemTypes.background
context.enrichedDescription = await foundry.applications.ux.TextEditor.implementation.enrichHTML(
@@ -187,4 +194,17 @@ export default class AwECharacterSheet extends AwEActorSheet {
const current = this.actor.system.flowPoints.value
this.actor.update({ "system.flowPoints.value": Math.max(0, current - 1) })
}
/**
* Roll the key attribute check from a Field item.
* @param {PointerEvent} event The triggering event.
* @param {HTMLElement} target The target element.
*/
static async #onRollField(event, target) {
const itemId = target.closest("[data-item-id]")?.dataset.itemId
const item = this.document.items.get(itemId)
if (!item) return
const attrId = target.dataset.attributeId ?? item.system.keyAttribute
await this.document.rollAttribute(attrId)
}
}
+6 -2
View File
@@ -37,8 +37,10 @@ export default class AwECharacter extends foundry.abstract.TypeDataModel {
// dc = 10 + mod (computed)
// bonus: manual +/- bonus
const attributeField = () => new fields.SchemaField({
boostLevel: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 4,
choices: {0:"0", 1:"1", 2:"2", 3:"3", 4:"4"} }),
// boosts: permanent +1 increments from background, field, step5, and level 3/6/9 progression
// max 7: 4 at creation + 3 from additional boosts at levels 3, 6, 9
boostLevel: new fields.NumberField({ ...requiredInteger, initial: 0, min: 0, max: 7,
choices: Object.fromEntries(Array.from({length: 8}, (_, i) => [i, String(i)])) }),
bonus: new fields.NumberField({ required: true, nullable: false, integer: true, initial: 0 })
})
@@ -61,6 +63,8 @@ export default class AwECharacter extends foundry.abstract.TypeDataModel {
const attr = this.attributes[attrId]
attr.mod = level + attr.boostLevel + attr.bonus
attr.dc = 10 + attr.mod
const bonusPart = attr.bonus !== 0 ? ` + Bonus ${attr.bonus >= 0 ? '+' : ''}${attr.bonus}` : ''
attr.modBreakdown = `Level ${level} + Boosts ${attr.boostLevel}${bonusPart} = ${attr.mod >= 0 ? '+' : ''}${attr.mod}`
}
}
}