Exact source used by this build. SHA-256: ef9e41d90e433b068cbe8a34892f95ceaa5055a33353300effea5fd8f53a1170.

1 import { z } from "zod";
2 
3 export const ItemSchema = z.object({
4   id: z.string().min(1), name: z.string().min(1), description: z.string(),
5   category: z.enum(["seed", "crop", "forage", "fish", "mineral", "artisan", "cooked", "material", "tool", "equipment", "furniture", "misc"]),
6   kind: z.string().optional(), cropId: z.string().min(1).nullable().optional(),
7   baseSellPrice: z.number().int().nonnegative(), stackMax: z.union([z.literal(1), z.literal(999)]),
8   qualityAllowed: z.boolean(), tags: z.string().array(),
9   legacyIds: z.string().array().default([]),
10   edibility: z.object({ value: z.number().int(), energy: z.number().int(), health: z.number().int() }).nullable(),
11 }).superRefine((item, ctx) => {
12   if (item.stackMax !== (["tool", "equipment"].includes(item.category) ? 1 : 999)) ctx.addIssue({ code: "custom", message: "Invalid category stack maximum" });
13   if (item.edibility && (item.edibility.energy !== Math.ceil(item.edibility.value * 2.5) || item.edibility.health !== Math.max(0, Math.floor(item.edibility.energy * .45)))) ctx.addIssue({ code: "custom", message: "Invalid edibility energy/health" });
14 }).transform((item) => ({ ...item, kind: item.category }));
15 export type Item = z.infer<typeof ItemSchema>;
16