|
| 1 | +import { z } from 'zod'; |
| 2 | +import { APIReferenceSchema, ChoiceSchema } from '../../src/schemas/common'; |
| 3 | + |
| 4 | +const SpellcastingInfoSchema = z.object({ |
| 5 | + name: z.string(), |
| 6 | + desc: z.array(z.string()), |
| 7 | +}); |
| 8 | + |
| 9 | +const SpellcastingSchema = z.object({ |
| 10 | + level: z.number(), |
| 11 | + spellcasting_ability: APIReferenceSchema, |
| 12 | + info: z.array(SpellcastingInfoSchema), |
| 13 | +}); |
| 14 | + |
| 15 | +const StartingEquipmentSchema = z.object({ |
| 16 | + equipment: APIReferenceSchema, |
| 17 | + quantity: z.number(), |
| 18 | +}); |
| 19 | + |
| 20 | +const MultiClassingPrereqSchema = z.object({ |
| 21 | + ability_score: APIReferenceSchema.optional(), |
| 22 | + minimum_score: z.number(), |
| 23 | +}); |
| 24 | + |
| 25 | +const MultiClassingSchema = z.object({ |
| 26 | + prerequisites: z.array(MultiClassingPrereqSchema).optional(), |
| 27 | + prerequisite_options: ChoiceSchema.optional(), |
| 28 | + proficiencies: z.array(APIReferenceSchema).optional(), |
| 29 | + proficiency_choices: z.array(ChoiceSchema).optional(), |
| 30 | +}); |
| 31 | + |
| 32 | +const PrimaryAbilitySchema = z.object({ |
| 33 | + desc: z.string(), |
| 34 | + all_of: z.array(APIReferenceSchema).optional(), |
| 35 | + any_of: ChoiceSchema.optional() |
| 36 | +}); |
| 37 | + |
| 38 | +export const ClassSchema = z.object({ |
| 39 | + index: z.string(), |
| 40 | + name: z.string(), |
| 41 | + primary_ability: PrimaryAbilitySchema, |
| 42 | + hit_die: z.number(), |
| 43 | + class_levels: z.string(), |
| 44 | + multi_classing: MultiClassingSchema.optional(), |
| 45 | + proficiencies: z.array(APIReferenceSchema).optional(), |
| 46 | + proficiency_choices: z.array(ChoiceSchema), |
| 47 | + saving_throws: z.array(APIReferenceSchema).optional(), |
| 48 | + starting_equipment: z.array(StartingEquipmentSchema).optional(), |
| 49 | + starting_equipment_options: z.array(ChoiceSchema), |
| 50 | + subclasses: z.array(APIReferenceSchema).optional(), |
| 51 | + spellcasting: SpellcastingSchema.optional(), |
| 52 | + spells: z.string().optional(), |
| 53 | + url: z.string(), |
| 54 | +}); |
0 commit comments