mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
Avoid fate scars update in place, with scars migrating to an integer value.
This commit is contained in:
parent
25646e30d6
commit
d2caa5f6d9
2 changed files with 13 additions and 26 deletions
|
|
@ -57,28 +57,15 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
|
||||||
if (config.roll.fate.value <= this.actor.system.levelData.level.current) {
|
if (config.roll.fate.value <= this.actor.system.levelData.level.current) {
|
||||||
// apply scarring - for now directly apply - later add a button.
|
// apply scarring - for now directly apply - later add a button.
|
||||||
console.log("Adding a scar...", this.actor.system.scars);
|
console.log("Adding a scar...", this.actor.system.scars);
|
||||||
const scar = {
|
const newScarAmount = this.actor.system.scars + 1;
|
||||||
[foundry.utils.randomID()]: {
|
|
||||||
name: "A scar " + this.actor.system.scars.length,
|
|
||||||
description: "A description"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log("scar", scar);
|
|
||||||
|
|
||||||
console.log('something goes here to update the scars data...');
|
await this.actor.update(
|
||||||
|
{
|
||||||
|
system: {
|
||||||
await this.actor.update(
|
scars: newScarAmount
|
||||||
{
|
|
||||||
system: {
|
|
||||||
scars: {
|
|
||||||
scar
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
);
|
||||||
{ overwrite: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
console.log("Adding a scar result", this.actor.system.scars);
|
console.log("Adding a scar result", this.actor.system.scars);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,12 +78,7 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
bags: new fields.NumberField({ initial: 0, integer: true }),
|
bags: new fields.NumberField({ initial: 0, integer: true }),
|
||||||
chests: new fields.NumberField({ initial: 0, integer: true })
|
chests: new fields.NumberField({ initial: 0, integer: true })
|
||||||
}),
|
}),
|
||||||
scars: new fields.TypedObjectField(
|
scars: new fields.NumberField({ initial: 0, integer: true, label: 'DAGGERHEART.GENERAL.scars' }),
|
||||||
new fields.SchemaField({
|
|
||||||
name: new fields.StringField({}),
|
|
||||||
description: new fields.StringField()
|
|
||||||
})
|
|
||||||
),
|
|
||||||
biography: new fields.SchemaField({
|
biography: new fields.SchemaField({
|
||||||
background: new fields.HTMLField(),
|
background: new fields.HTMLField(),
|
||||||
connections: 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
|
? armor.system.baseThresholds.severe + this.levelData.level.current
|
||||||
: this.levelData.level.current * 2
|
: 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;
|
this.resources.hitPoints.max += this.class.value?.system?.hitPoints ?? 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -705,4 +700,9 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
t => !!t
|
t => !!t
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static migrateData(source) {
|
||||||
|
if (typeof (source.scars) === 'object') source.scars = 0;
|
||||||
|
return super.migrateData(source);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue