import { PhysicalItemData } from "./base-item.mjs";
const fields = foundry.data.fields;

export default class WeaponData extends PhysicalItemData {
    static defineSchema() {
        const schema = super.defineSchema();
        schema.equipped = new fields.BooleanField({ required: false, initial: false });
        schema.range = new fields.SchemaField({
            isMelee: new fields.BooleanField({ required: false, initial: false }),
            value: new fields.NumberField({ required: false, integer: true, nullable: true }),
            unit: new fields.StringField({ required: false, blank: true, nullable: true })
        });
        schema.damage = new fields.StringField({ required: false, blank: true, trim: true });
        schema.magazine = new fields.NumberField({ required: false, initial: 0, min: 0, integer: true });
        schema.magazineCost = new fields.NumberField({ required: false, initial: 0, min: 0, integer: true });
        schema.traits = new fields.ArrayField(
            new fields.SchemaField({
                name: new fields.StringField({ required: true, blank: true, trim: true }),
                description: new fields.StringField({ required: false, blank: true, trim: true })
            })
        );
        schema.options = new fields.ArrayField(
            new fields.SchemaField({
                name: new fields.StringField({ required: true, blank: true, trim: true }),
                description: new fields.StringField({ required: false, blank: true, trim: true })
            })
        );
        return schema;
    }
}
