import { z } from "zod"; import { baySchema, companySchema, contractSchema, dispatchSchema, idSchema, pilotSchema, playerStateSchema, shipSchema, timeSchema, } from "./entities"; /** Request with no body or parameters. */ export const emptyRequestSchema = z.object({}).strict(); export const createGuestResponseSchema = z.object({ playerId: idSchema, state: playerStateSchema, }); export const contractBoardRequestSchema = z.object({ locationId: idSchema }); export const contractBoardResponseSchema = z.object({ contracts: z.array(contractSchema), /** When this board period ends and every contract on it expires. */ periodEndsAt: timeSchema, }); export const createDispatchRequestSchema = z.discriminatedUnion("kind", [ z.object({ kind: z.literal("contract"), contractId: idSchema, shipId: idSchema, pilotId: idSchema, }), /** The avatar flies the loaner; no ship or pilot to choose. */ z.object({ kind: z.literal("tutorial"), contractId: idSchema }), z.object({ kind: z.literal("reposition"), shipId: idSchema, pilotId: idSchema, destinationId: idSchema, }), ]); export type CreateDispatchRequest = z.infer; export const dispatchResponseSchema = z.object({ dispatch: dispatchSchema }); /** Decision 0.5.35: the ship is delivered to one of the player's bays. */ export const buyShipRequestSchema = z.object({ modelId: idSchema, bayId: idSchema }); export const shipResponseSchema = z.object({ ship: shipSchema }); export const leaseBayRequestSchema = z.object({ locationId: idSchema }); export const bayResponseSchema = z.object({ bay: baySchema }); /** Decision 0.5.22: hire at one of the player's bays. */ export const hirePilotRequestSchema = z.object({ locationId: idSchema }); export const assignPilotRequestSchema = z.object({ pilotId: idSchema, shipId: idSchema }); export const unassignPilotRequestSchema = z.object({ pilotId: idSchema }); export const spendSkillPointRequestSchema = z.object({ pilotId: idSchema, skillId: idSchema }); export const pilotResponseSchema = z.object({ pilot: pilotSchema }); export const acknowledgeSummariesRequestSchema = z.object({ dispatchIds: z.array(idSchema).min(1), }); export const acknowledgeSummariesResponseSchema = z.object({ acknowledged: z.number().int().nonnegative(), }); /** Pay the loan down by up to `amount` credits (decision 0.5.32). */ export const repayLoanRequestSchema = z.object({ amount: z.number().int().positive() }); export const claimGoalRequestSchema = z.object({ goalId: idSchema }); export const companyResponseSchema = z.object({ company: companySchema });