feat: continuing to add data models
This commit is contained in:
69
modules/dataModel/dataModel.mjs
Normal file
69
modules/dataModel/dataModel.mjs
Normal file
@@ -0,0 +1,69 @@
|
||||
/* -------------------------------------------- */
|
||||
/* Base Models */
|
||||
/* -------------------------------------------- */
|
||||
const fields = foundry.data.fields;
|
||||
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})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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 */
|
||||
/* -------------------------------------------- */
|
||||
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}),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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" })
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class Strength extends Effect
|
||||
{
|
||||
static defineSchema() {
|
||||
return {
|
||||
...super.defineSchema(),
|
||||
name: new fields.StringField({ required: true, initial: "Strength"})
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user