/**
 * Data model for Feature items
 */
export default class BoLFeatureDataModel extends foundry.abstract.TypeDataModel {
  static defineSchema() {
    const fields = foundry.data.fields;
    const requiredInteger = { required: true, nullable: false, integer: true };
    const nullableNumber = { required: false, nullable: true, initial: null };

    return {
      // Base fields
      category: new fields.StringField({ initial: "" }),
      subtype: new fields.StringField({ initial: "default" }),
      description: new fields.HTMLField({ initial: "" }),
      properties: new fields.SchemaField({
        // Career
        sorcerer: new fields.BooleanField({ initial: false }),
        alchemist: new fields.BooleanField({ initial: false }),
        priest: new fields.BooleanField({ initial: false }),
        astrologer: new fields.BooleanField({ initial: false }),

        // Boon
        isbonusdice: new fields.BooleanField({ initial: false }),

        // Flaw
        ismalusdice: new fields.BooleanField({ initial: false }),

        // Fight option
        fightoptiontype: new fields.StringField({ initial: "" }),
        activated: new fields.BooleanField({ initial: false }),
        isspecial: new fields.BooleanField({ initial: false }),

        // Effect (boleffect)
        identifier: new fields.StringField({ initial: "" }),
        modifier: new fields.StringField({ initial: "" }),

        // Horoscope
        horoscopeanswer: new fields.StringField({ initial: "" }),
        rank: new fields.NumberField({ ...nullableNumber }),

        // XP log
        xptype: new fields.StringField({ initial: "" }),
        xpdate: new fields.StringField({ initial: "" }),
        xpname: new fields.StringField({ initial: "" }),
        xpcost: new fields.NumberField({ ...nullableNumber }),
        xpvalue: new fields.NumberField({ ...nullableNumber }),
      }),

      // Feature-specific fields
      rank: new fields.NumberField({ ...requiredInteger, initial: 0 })
    };
  }

  static LOCALIZATION_PREFIXES = ["BOL.Feature"];
}
