diff --git a/module/data/Actor/Hero.mjs b/module/data/Actor/Hero.mjs index 44c2129..723c512 100644 --- a/module/data/Actor/Hero.mjs +++ b/module/data/Actor/Hero.mjs @@ -1,3 +1,4 @@ +import { barAttribute } from "../helpers.mjs"; import { gameTerms } from "../../gameTerms.mjs"; const { fields } = foundry.data; @@ -35,6 +36,7 @@ export class HeroData extends foundry.abstract.TypeDataModel { nullable: false, }), }), + guts: barAttribute(0, 5), coin: new fields.SchemaField({ gold: new fields.NumberField({ initial: 5, diff --git a/module/data/helpers.mjs b/module/data/helpers.mjs new file mode 100644 index 0000000..37d92c2 --- /dev/null +++ b/module/data/helpers.mjs @@ -0,0 +1,20 @@ +const { fields } = foundry.data; + +export function barAttribute(min, initial, max = undefined) { + return new fields.SchemaField({ + value: new fields.NumberField({ + min, + initial, + max, + integer: true, + nullable: false, + }), + max: new fields.NumberField({ + min, + initial, + max, + integer: true, + nullable: false, + }), + }); +};