Skip to content

Commit e413273

Browse files
feat: update 2024 ClassSchema with primary_ability logic (#1066)
## What does this do? Added the schema for 2024 classes to prepare for classes upload. This only added a Primary Abilities Schema compared to 2014. ## How was it tested? Matched against "correct" formatting ## Is there a Github issue this is resolving? No ## Did you update the docs in the API? Please link an associated PR if applicable. No ## Here's a fun image for your troubles My cat as a baby, please enjoy ![38260471_10216390722141710_3268489959299874816_n](https://github.com/user-attachments/assets/3b9d1dac-d1a9-4740-bf5f-13efc6a766d6)
1 parent d36e395 commit e413273

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

src/2024/schemas/5e-SRD-Classes.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { z } from 'zod';
2+
import { APIReferenceSchema, ChoiceSchema } from '../../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

Comments
 (0)