diff --git a/module/applications/dialogs/deathMove.mjs b/module/applications/dialogs/deathMove.mjs index ca00df82..2d9b18b7 100644 --- a/module/applications/dialogs/deathMove.mjs +++ b/module/applications/dialogs/deathMove.mjs @@ -57,28 +57,15 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV if (config.roll.fate.value <= this.actor.system.levelData.level.current) { // apply scarring - for now directly apply - later add a button. console.log("Adding a scar...", this.actor.system.scars); - const scar = { - [foundry.utils.randomID()]: { - name: "A scar " + this.actor.system.scars.length, - description: "A description" - } - } - console.log("scar", scar); + const newScarAmount = this.actor.system.scars + 1; - console.log('something goes here to update the scars data...'); - - - await this.actor.update( - { - system: { - scars: { - scar + await this.actor.update( + { + system: { + scars: newScarAmount } } - }, - { overwrite: true } - ); - + ); console.log("Adding a scar result", this.actor.system.scars); } diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index 5bce5c55..448fba98 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -78,12 +78,7 @@ export default class DhCharacter extends BaseDataActor { bags: new fields.NumberField({ initial: 0, integer: true }), chests: new fields.NumberField({ initial: 0, integer: true }) }), - scars: new fields.TypedObjectField( - new fields.SchemaField({ - name: new fields.StringField({}), - description: new fields.StringField() - }) - ), + scars: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.scars' }), biography: new fields.SchemaField({ background: new fields.HTMLField(), connections: new fields.HTMLField(), @@ -633,7 +628,7 @@ export default class DhCharacter extends BaseDataActor { ? armor.system.baseThresholds.severe + this.levelData.level.current : this.levelData.level.current * 2 }; - this.resources.hope.max -= Object.keys(this.scars).length; + this.resources.hope.max -= this.scars; this.resources.hitPoints.max += this.class.value?.system?.hitPoints ?? 0; } @@ -705,4 +700,9 @@ export default class DhCharacter extends BaseDataActor { t => !!t ); } + + static migrateData(source) { + if (typeof (source.scars) === 'object') source.scars = 0; + return super.migrateData(source); + } }