This commit is contained in:
Joscha Maier
2024-09-29 14:58:03 +02:00
parent c9acf8b9ff
commit bcf1d8827d
6 changed files with 245 additions and 3 deletions

View File

@@ -0,0 +1,106 @@
const fields = foundry.data.fields;
/* -------------------------------------------- */
/* Base Models */
/* -------------------------------------------- */
class Stat extends foundry.abstract.DataModel
{
static defineSchema() {
return {
id: new StringField({ required: true, initial: "statID"}),
name: new StringField({ required: true, intial: "Stat"}),
die: new NumberField({ required: true, integer: true, min: 0, max: 20, initial: 4}),
modifiers: new ArrayField({ required: true, type: Modifier, default: []}),
};
}
}
class Modifier extends foundry.abstract.DataModel
{
static defineSchema() {
return {
statID: new StringField({ required: true, initial: "statID"}),
name: new StringField({ required: true, initial: "Modifier"}),
value: new NumberField({ required: true, integer: true, initial: 0}),
};
}
Modifier(statID,name,value) {
this.statID = statID;
this.name = name;
this.value = value;
};
}
/* -------------------------------------------- */
/* Effect Models */
/* -------------------------------------------- */
class EffectDataModel extends foundry.abstract.DataModel
{
static defineSchema() {
return {
description: new StringField({ required: true, initial: "A EffectDescription" }),
modifier: new EmbeddedDataField(Modifier, { required: true, nullable: true, default: null}),
};
}
}
class Flaw extends foundry.abstract.DataModel
{
static defineSchema() {
return {
name: new StringField({ required: true, initial: "Flaw"}),
description: new StringField({ required: true, initial: "A FlawDescription" })
};
}
}
class Strength extends EffectDataModel
{
static defineSchema() {
return {
...super.defineSchema(),
name: new StringField({ required: true, initial: "Strength"})
};
}
}
/* -------------------------------------------- */
/* Item Models */
/* -------------------------------------------- */
/* How this will work is when we first load a sheet we load all the items we have and take their effects and apply them to our stats. */
class Item extends foundry.abstract.TypeDataModel
{
static defineSchema() {
return {
name: new StringField({ required: true, initial: "Item"}),
description: new StringField({ required: true, initial: "An ItemDescription" }),
effects: new ArrayField({ required: true, type: EffectDataModel, default: []}),
};
}
Item(name,description,effects) {
this.name = name;
this.description = description;
this.effects = effects;
}
}
class Wand extends Item
{
static defineSchema() {
return {
name: new StringField({ required: true, initial: "Wand"}),
wood: new EmbeddedDataField(Item, { required: true, nullable: true, default: null}), //These are just items!
core: new EmbeddedDataField(Item, { required: true, nullable: true, default: null}),
};
}
}
/* -------------------------------------------- */
/* Actor Models */
/* -------------------------------------------- */

View File