fvtt-never-stop-blowing-up/modules/dataModel/dataModel.mjs
2024-10-07 14:12:05 +02:00

72 lines
2.2 KiB
JavaScript

/* -------------------------------------------- */
/* Base Models */
/* -------------------------------------------- */
const fields = foundry.data.fields;
export default class Stat extends foundry.abstract.DataModel
{
static defineSchema() {
return {
id: new fields.StringField({ required: true, initial: "statID"}),
name: new fields.StringField({ required: true, intial: "Stat"}),
die: new fields.NumberField({ required: true, nullable: false, initial: "d4"}),
modifiers: new fields.ArrayField({ required: true, type: Modifier, default: []}),
modifier: new fields.NumberField({required: true, integer: true, initial: 0})
};
}
}
export class Modifier extends foundry.abstract.DataModel
{
static defineSchema() {
return {
statID: new fields.StringField({ required: true, initial: "statID"}),
name: new fields.StringField({ required: true, initial: "Modifier"}),
value: new fields.NumberField({ required: true, integer: true, initial: 0}),
};
}
Modifier(statID,name,value) {
this.statID = statID;
this.name = name;
this.value = value;
};
}
/* -------------------------------------------- */
/* Effect Models */
/* -------------------------------------------- */
export class Effect extends foundry.abstract.DataModel
{
static defineSchema() {
return {
description: new fields.StringField({ required: true, initial: "A EffectDescription" }),
modifier: new fields.EmbeddedDataField(Modifier, { required: true, nullable: true, default: null}),
};
}
}
export class Flaw extends foundry.abstract.DataModel
{
static defineSchema() {
return {
name: new fields.StringField({ required: true, initial: "Flaw"}),
description: new fields.StringField({ required: true, initial: "A FlawDescription" })
};
}
}
export class Strength extends Effect
{
static defineSchema() {
return {
...super.defineSchema(),
name: new fields.StringField({ required: true, initial: "Strength"})
};
}
}