import { STRING, HTMLSTRING } from "../common/field-types.mjs"; import { statField, santeField, attributField, compteurField } from "./_actor-helpers.mjs"; const fields = foundry.data.fields; export default class RdDModelCreature extends foundry.abstract.TypeDataModel { static defineSchema() { return { carac: new fields.SchemaField({ taille: statField(10, "Taille"), constitution: statField(10, "Constitution"), force: statField(10, "Force"), perception: statField(10, "Perception"), volonte: statField(10, "Volonté"), reve: statField(10, "Rêve"), }), sante: new fields.SchemaField({ vie: santeField(10, 10, "Vie"), endurance: santeField(10, 10, "Endurance"), bonusPotion: new fields.NumberField({ initial: 0, integer: true }), }), attributs: new fields.SchemaField({ plusdom: attributField(0, "+dom", true), encombrement: attributField(0.0, "Encombrement", true), vitesse: attributField(0, "Vitesse", false, true), protection: attributField(0, "Protection naturelle", false), }), compteurs: new fields.SchemaField({ etat: compteurField(0, "Etat général"), }), description: new fields.HTMLField({ initial: "", ...HTMLSTRING }), race: new fields.StringField({ initial: "", ...STRING }), notesmj: new fields.HTMLField({ initial: "", ...HTMLSTRING }), }; } prepareDerivedData() { const actor = this.parent; this.sante.vie.max = Math.ceil((actor.getTaille() + actor.getConstitution()) / 2); this.sante.vie.value = Math.min(this.sante.vie.value, this.sante.vie.max); this.attributs.encombrement.value = actor.getEncombrementMax(); this.attributs.plusdom.value = actor.getBonusDegat(); this.sante.endurance.max = actor.getEnduranceMax(); this.sante.endurance.value = Math.min(this.sante.endurance.value, this.sante.endurance.max); } }