fvtt-never-stop-blowing-up/modules/dataModel/dataModel.mjs

72 lines
2.2 KiB
JavaScript
Raw Normal View History

2024-10-02 00:14:03 +02:00
/* -------------------------------------------- */
/* Base Models */
/* -------------------------------------------- */
const fields = foundry.data.fields;
2024-10-02 14:45:44 +02:00
export default class Stat extends foundry.abstract.DataModel
2024-10-02 00:14:03 +02:00
{
2024-10-07 14:12:05 +02:00
2024-10-02 00:14:03 +02:00
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})
};
}
2024-10-07 14:12:05 +02:00
2024-10-02 00:14:03 +02:00
}
2024-10-02 14:45:44 +02:00
export class Modifier extends foundry.abstract.DataModel
2024-10-02 00:14:03 +02:00
{
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 */
/* -------------------------------------------- */
2024-10-02 14:45:44 +02:00
export class Effect extends foundry.abstract.DataModel
2024-10-02 00:14:03 +02:00
{
static defineSchema() {
return {
description: new fields.StringField({ required: true, initial: "A EffectDescription" }),
modifier: new fields.EmbeddedDataField(Modifier, { required: true, nullable: true, default: null}),
};
}
}
2024-10-02 14:45:44 +02:00
export class Flaw extends foundry.abstract.DataModel
2024-10-02 00:14:03 +02:00
{
static defineSchema() {
return {
name: new fields.StringField({ required: true, initial: "Flaw"}),
description: new fields.StringField({ required: true, initial: "A FlawDescription" })
};
}
}
2024-10-02 14:45:44 +02:00
export class Strength extends Effect
2024-10-02 00:14:03 +02:00
{
static defineSchema() {
return {
...super.defineSchema(),
name: new fields.StringField({ required: true, initial: "Strength"})
};
}
}