import { z } from 'zod';
import { PerkSchema } from './perk';

export const SurvivorStateSchema = z.enum([
  'idle',
  'active',
  'injured',
  'downed',
  'sacrificed',
]);
export type SurvivorState = z.infer<typeof SurvivorStateSchema>;

export const SurvivorStatsSchema = z.object({
  objectives: z.number().int().min(1).max(10),
  survival: z.number().int().min(1).max(10),
  altruism: z.number().int().min(1).max(10),
});
export type SurvivorStats = z.infer<typeof SurvivorStatsSchema>;

export const SurvivorSchema = z.object({
  id: z.uuid(),
  opaqueUserId: z.string().regex(/^U/, 'Must be a logged-in viewer opaque user ID'),
  channelId: z.string().min(1),
  name: z.string().min(1).max(32),
  state: SurvivorStateSchema,
  stats: SurvivorStatsSchema,
  perkSlots: z.array(PerkSchema).max(4),
  createdAt: z.iso.datetime(),
});
export type Survivor = z.infer<typeof SurvivorSchema>;
