Update readme with schemas
This commit is contained in:
parent
d1b632e83c
commit
655a105924
2 changed files with 136 additions and 23 deletions
|
@ -17,18 +17,14 @@ import {
|
|||
import { z } from "zod";
|
||||
|
||||
const Base = z.object({
|
||||
// Required -- defines the type of component
|
||||
$define: z.string(),
|
||||
});
|
||||
|
||||
const Info = Base.extend({
|
||||
id: z.string(), // TODO: Validate ID shapes
|
||||
name: z.string().default("Unnamed Component"),
|
||||
description: z.string().default("No description provided"),
|
||||
categories: z.array(z.string()).default([]),
|
||||
});
|
||||
|
||||
const AbilitySchema = Info.extend({
|
||||
const AbilitySchema = Base.extend({
|
||||
$define: z.literal("ability"),
|
||||
type: z.string().default("action"),
|
||||
ap: z.number().int().default(0),
|
||||
|
@ -40,7 +36,7 @@ const AbilitySchema = Info.extend({
|
|||
roll: z.string().default("none"),
|
||||
});
|
||||
|
||||
const BlueprintSchema = Info.extend({
|
||||
const BlueprintSchema = Base.extend({
|
||||
$define: z.literal("blueprint"),
|
||||
species: z.string(),
|
||||
items: z.array(z.string()).default([]),
|
||||
|
@ -62,7 +58,7 @@ const GlossarySchema = Base.extend({
|
|||
terms: z.record(z.string(), z.string()),
|
||||
});
|
||||
|
||||
const BaseItem = Info.extend({
|
||||
const BaseItem = Base.extend({
|
||||
$define: z.literal("item"),
|
||||
rarity: z.string().default("common"),
|
||||
affinity: z.string().default("none"),
|
||||
|
@ -78,43 +74,43 @@ const ItemSchema = z.discriminatedUnion("type", [
|
|||
}),
|
||||
BaseItem.extend({
|
||||
type: z.literal("worn"),
|
||||
hands: z.number().int().default(1),
|
||||
slot: z.string().default("unique"),
|
||||
}),
|
||||
BaseItem.extend({
|
||||
type: z.literal("trinket"),
|
||||
}),
|
||||
]);
|
||||
|
||||
const MethodSchema = Info.extend({
|
||||
const MethodSchema = Base.extend({
|
||||
$define: z.literal("method"),
|
||||
curator: z.string().default("Someone"),
|
||||
abilities: z.array(z.array(z.string())).default([]),
|
||||
});
|
||||
|
||||
const ResourceSchema = z.discriminatedUnion("type", [
|
||||
Info.extend({
|
||||
Base.extend({
|
||||
$define: z.literal("resource"),
|
||||
type: z.literal("text"),
|
||||
}),
|
||||
Info.extend({
|
||||
Base.extend({
|
||||
$define: z.literal("resource"),
|
||||
type: z.literal("image"),
|
||||
url: z.string(),
|
||||
}),
|
||||
Info.extend({
|
||||
Base.extend({
|
||||
$define: z.literal("resource"),
|
||||
type: z.literal("table"),
|
||||
data: z.array(z.array(z.string())),
|
||||
}),
|
||||
]);
|
||||
|
||||
const RuleSchema = Info.extend({
|
||||
const RuleSchema = Base.extend({
|
||||
$define: z.literal("rule"),
|
||||
overrule: z.nullable(z.string()).default(null),
|
||||
order: z.number().int().default(Number.POSITIVE_INFINITY),
|
||||
});
|
||||
|
||||
const SpeciesSchema = Info.extend({
|
||||
const SpeciesSchema = Base.extend({
|
||||
$define: z.literal("species"),
|
||||
hands: z.number().int().default(2),
|
||||
abilities: z.array(z.string()).default([]),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue