import {z} from "zod";
import {TeamSchema} from "./team.js";
import {PlayerSchema} from "./data.js";

export const ShortEventSchema = z.object({
    id: z.number(),
    name: z.string(),
    start: z.number(),
    end: z.number(),
})

export type ShortEvent = z.infer<typeof ShortEventSchema>;

export const SWEventSchema = ShortEventSchema.extend({
    deadline: z.number(),
    maxTeamMembers: z.number(),
    schemType: z.string().nullable(),
    publicSchemsOnly: z.boolean(),
    spectateSystem: z.boolean(),
})

export type SWEvent = z.infer<typeof SWEventSchema>;

export const EventFightSchema = z.object({
    id: z.number(),
    spielmodus: z.string(),
    map: z.string(),
    blueTeam: TeamSchema,
    redTeam: TeamSchema,
    kampfleiter: PlayerSchema.nullable(),
    start: z.number(),
    ergebnis: z.number(),
    group: z.string().nullable(),
})

export type EventFight = z.infer<typeof EventFightSchema>;

export const ExtendedEventSchema = z.object({
    event: SWEventSchema,
    teams: z.array(TeamSchema),
    fights: z.array(EventFightSchema),
})

export type ExtendedEvent = z.infer<typeof ExtendedEventSchema>;
