import { z } from 'zod';
import { PerkModifierTargetSchema, PerkModifierTypeSchema } from './perk';
import { SurvivorStateSchema } from './survivor';

export const ModifierApplicationSchema = z.object({
  perkKey: z.string().min(1),
  target: PerkModifierTargetSchema,
  type: PerkModifierTypeSchema,
  effectiveAmount: z.number(),
});
export type ModifierApplication = z.infer<typeof ModifierApplicationSchema>;

export const EncounterResultSchema = z.object({
  missionId: z.uuid(),
  survivorId: z.uuid(),
  encounterKey: z.string().min(1),
  tickIndex: z.number().int().min(0),
  seed: z.string().min(1),
  success: z.boolean(),
  survivorStateChange: z
    .object({
      from: SurvivorStateSchema,
      to: SurvivorStateSchema,
    })
    .nullable(),
  modifiersApplied: z.array(ModifierApplicationSchema),
  logText: z.string().min(1),
});
export type EncounterResult = z.infer<typeof EncounterResultSchema>;
