diff --git a/module/applications/sheets/character-sheet.mjs b/module/applications/sheets/character-sheet.mjs index ff6dc81..7fe3f72 100644 --- a/module/applications/sheets/character-sheet.mjs +++ b/module/applications/sheets/character-sheet.mjs @@ -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) + } } diff --git a/module/models/character.mjs b/module/models/character.mjs index 88d2f9e..4a881fc 100644 --- a/module/models/character.mjs +++ b/module/models/character.mjs @@ -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}` } } } diff --git a/templates/character-biography.hbs b/templates/character-biography.hbs index 1b6ab5e..772507b 100644 --- a/templates/character-biography.hbs +++ b/templates/character-biography.hbs @@ -19,6 +19,16 @@