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

48 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-10-02 00:14:03 +02:00
import ActorGeneral from "./baseActorModel.mjs";
2024-10-02 14:45:44 +02:00
import {Wand, Broom} from "./itemModel.mjs"
import KidsOnBroomsItem from "./itemModel.mjs"
2024-10-02 00:14:03 +02:00
/* -------------------------------------------- */
/* PC Model */
/* -------------------------------------------- */
const fields = foundry.data.fields;
2024-10-02 14:45:44 +02:00
export default class PlayerCharacter extends ActorGeneral
2024-10-02 00:14:03 +02:00
{
static defineSchema(){
return {
...super.defineSchema(),
description: new fields.StringField({required: false, intial: "Enter your characters description here."}),
broom: new fields.EmbeddedDataField(Broom, {nullable: true}),
wand: new fields.EmbeddedDataField(Wand, {nullable: true}),
animalFamiliar: new fields.StringField({required: false, initial: "Describe your companion!"}),
schoolbag: new fields.ArrayField({type: KidsOnBroomsItem, default: []}),
strengths: new fields.ArrayField({type: Strength, default: []}),
adversityTokens: new fields.NumberField({required: true, nullable: false, integer: true, initial: 3, min: 0})
}
}
2024-10-19 23:02:28 +02:00
static LOCALISATION_PREFIXES = ["PlayerCharacter"];
2024-11-04 00:47:13 +01:00
2024-10-02 00:14:03 +02:00
prepareBaseData() {
2024-10-07 14:12:05 +02:00
super.prepareBaseData();
2024-10-02 00:14:03 +02:00
let effectsToApply = this.gatherEffects();
effectsToApply.forEach(element => {
2024-10-07 14:12:05 +02:00
console.log(element);
2024-10-02 00:14:03 +02:00
})
}
gatherEffects() {
let effectsToApply = new [];
this.schoolbag.array.forEach(element => {
if(element.effects != []) {
element.effects.forEach(effect => {
effectsToApply.push(effect);
})
}
});
return effectsToApply;
}
}