import { z } from "zod"; // Asset library: model appearances (see ./appearance.ts). import { appearanceSchema } from "./appearance.js"; /** * Zod schemas for everything a game declares ("Everything * is typed with Zod schemas, so a bad prefab fails at build with a message * the agent can act on"). Messages are written for the agent that reads them. */ /** Templates carry the genre machinery; the model adds content and rules. */ export const TEMPLATES = ["survivor", "arena", "dungeon", "racer", "platformer", "tower-defense", "party", "idle", "cards", "collector"] as const; /** Art styles of the asset library (§10). */ export const STYLES = ["pixel", "lowpoly", "toon", "voxel", "ps1", "handdrawn"] as const; const ID = /^[a-z][a-z0-9_]{0,47}$/; /** Library asset ids look like `style.lowpoly.mech_01`. Never a URL (§10). */ const ASSET_ID = /^style\.[a-z0-9]+\.[a-z0-9_]+$/; export const idSchema = z .string() .regex(ID, "ids are lower_snake_case: start with a letter, then a-z, 0-9 or _, at most 48 characters"); export const assetIdSchema = z .string() .refine((s) => !/^[a-z]+:\/\//i.test(s) && !s.startsWith("/") && !s.startsWith("data:"), { message: "reference assets by library id (e.g. \"style.lowpoly.bat\"), never by URL or path", }) .refine((s) => ASSET_ID.test(s), { message: "asset ids look like \"style.