Spaces:
Paused
Paused
| import { Type } from "@google/genai"; | |
| import { z } from "zod"; | |
| export const heroFormSchema = z.object({ | |
| _id: z.string(), | |
| heroName: z.string().min(2, "Name must be at least 2 characters."), | |
| heroGender: z.enum(["Male", "Female"]), | |
| heroDescription: z.string().min(10, "Description is too short."), | |
| heroColor: z.string().regex(/^#[0-9a-fA-F]{6}$/, "Must be a valid hex color."), | |
| heroHealth: z.number().int().min(50), | |
| heroSpeed: z.number().min(0.5), | |
| basicAttack: z.object({ | |
| type: z.enum(['RANGED', 'MELEE', 'CONTACT']), | |
| damage: z.number().min(1), | |
| cooldown: z.number().min(0.5), | |
| range: z.number().min(0), | |
| }), | |
| powerName: z.string().min(3, "Power name is too short."), | |
| powerDescription: z.string().min(10, "Power description is too short."), | |
| powerLogicDescription: z.string().min(10, "Power logic description is too short."), | |
| powerLogic: z.string().min(20, "Power logic code seems too short."), | |
| introLine: z.string().min(5, "Intro line is too short."), | |
| superpowerActivationLine: z.string().min(5, "Activation line is too short."), | |
| avatarPrompt: z.string().min(10), | |
| iconPrompt: z.string().min(10), | |
| avatarUrl: z.string().url("Must be a valid URL."), | |
| iconUrl: z.string().url("Must be a valid URL."), | |
| introLineAudioUrl: z.string().url().optional().nullable(), | |
| superpowerActivationLineAudioUrl: z.string().url().optional().nullable(), | |
| tags: z.array(z.string()).optional(), | |
| }); | |
| export const heroDataSchema = { | |
| type: Type.OBJECT, | |
| properties: { | |
| heroName: { type: Type.STRING }, | |
| heroGender: { type: Type.STRING }, | |
| heroDescription: { type: Type.STRING }, | |
| heroColor: { type: Type.STRING }, | |
| heroHealth: { type: Type.NUMBER }, | |
| heroSpeed: { type: Type.NUMBER }, | |
| basicAttack: { | |
| type: Type.OBJECT, | |
| properties: { | |
| type: { type: Type.STRING }, // e.g., "RANGED", "MELEE", "CONTACT" | |
| damage: { type: Type.NUMBER }, | |
| cooldown: { type: Type.NUMBER }, | |
| range: { type: Type.NUMBER }, | |
| knockback: { type: Type.NUMBER }, | |
| }, | |
| required: ["type", "damage", "cooldown", "range", "knockback"], | |
| }, | |
| powerName: { type: Type.STRING }, | |
| powerDescription: { type: Type.STRING }, | |
| powerLogicDescription: { type: Type.STRING }, | |
| introLine: { type: Type.STRING }, | |
| superpowerActivationLine: { type: Type.STRING }, | |
| avatarPrompt: { type: Type.STRING }, | |
| iconPrompt: { type: Type.STRING }, | |
| tags: { type: Type.ARRAY, items: { type: Type.STRING } }, | |
| }, | |
| required: [ | |
| "heroName", | |
| "heroGender", | |
| "heroDescription", | |
| "heroColor", | |
| "heroHealth", | |
| "heroSpeed", | |
| "basicAttack", | |
| "powerName", | |
| "powerDescription", | |
| "powerLogicDescription", | |
| "introLine", | |
| "superpowerActivationLine", | |
| "avatarPrompt", | |
| "iconPrompt", | |
| "tags", | |
| ], | |
| }; |