import { z } from 'zod';
import { colorNameSchema } from '../color';
import { damageEffectNameSchema } from '../damage';
import { gameTypeSchema } from '../game';
import { kartHardwareStateSchema } from '../hardware/KartHardwareState.schema';
import { powerUpNameSchema } from '../powerUp/PowerUpAttributes.schema';
import { KART_STATUS } from './Kart.const';

export const kartStatusSchema = z.enum(KART_STATUS);

export const kartShieldSchema = z.object({
  isActive: z.boolean(),
  duration: z.number(),
});

export const kartGameSchema = z.object({
  id: z.number(),
  type: gameTypeSchema,
});

export const kartSchema = z.object({
  guid: z.string(),
  id: z.number(),
  mac: z.string(),
  hostname: z.string(),
  isConnected: z.boolean(),
  status: kartStatusSchema,
  shield: kartShieldSchema,
  gameTrackId: z.string(),
  color: colorNameSchema,
  number: z.number(),
  currentGame: kartGameSchema.nullable().optional(),
  description: z.string().nullable().optional(),
  isSubscribedToHardwareStatus: z.boolean(),
  hardwareState: kartHardwareStateSchema.nullable().optional(),
  currentPowerUp: powerUpNameSchema.nullable().optional(),
  currentDamage: damageEffectNameSchema.nullable().optional(),
});
