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

149 lines
4.9 KiB
JavaScript

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 Effect 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 Effect
{
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: Effect, default: []}),
};
}
Item(name,description,effects) {
this.name = name;
this.description = description;
this.effects = effects;
}
}
class Wand extends foundry.abstract.DataModel
{
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}),
};
}
}
class Broom extends foundry.abstact.DataModel
{
static defineSchema(){
return {
name: new StringField({required: true, initial: "Broom"}),
look: new StringField({requird: true, intial: "A broom"}),
mechanicalBenefit: new EmbeddedDataField(effect, {required: false})
}
}
}
/* -------------------------------------------- */
/* Actor Models */
/* -------------------------------------------- */
class ActorGeneral extends foundry.abstract.TypeDataModel
{
static defineSchema(){
return {
name: new StringField({required: true, initial: "Actor"}),
age: new StringField({required: false}),
pronouns: new StringField({required: false}),
fear: new StringField({required: false}),
grade: new StringField({required: false}),
stats: new SchemaField({
fight: new EmbeddedDataField(Stat, {required: true, nullable: false, default: new Stat()}),
brains: new EmbeddedDataField(Stat, {required: true, nullable: false, default: new Stat()}),
charm: new EmbeddedDataField(Stat, {required: true, nullable: false, default: new Stat()}),
flight: new EmbeddedDataField(Stat, {required: true, nullable: false, default: new Stat()}),
brawn: new EmbeddedDataField(Stat, {required: true, nullable: false, default: new Stat()}),
grit: new EmbeddedDataField(Stat, {required: true, nullable: false, default: new Stat()}),
}),
}
}
}
class PlayerCharacter extends ActorGeneral
{
static defineSchema(){
return {
...super.defineSchema(),
}
}
}