import { operation, buildingBase, buildingCommonMethods, buildingView, requestBodySchema, response200, response500, security, statusSchema, tags, } from '../../chunks.ts'; const base = buildingBase('Shipyard'); const shipsBuildingSchema = { type: 'object', required: ['status', 'number_of_ships_building', 'cost_to_subsidize', 'ships_building'], properties: { status: statusSchema(), number_of_ships_building: { type: 'integer' }, cost_to_subsidize: { type: 'integer' }, ships_building: { type: 'array', items: { type: 'object', required: ['id', 'type', 'type_human', 'date_completed'], properties: { id: { type: 'integer' }, type: { type: 'string' }, type_human: { type: 'string' }, date_completed: { type: 'string' }, }, }, }, }, }; const buildingIdRequestBody = requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' } }, }); export const shipyard = { ...buildingCommonMethods(base), ...buildingView(base), [`${base}/view_build_queue`]: { post: { ...tags(base), ...security(), ...operation( 'View build queue.', 'Retrieves the ships currently being built at this shipyard.' ), ...requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, page_number: { type: 'integer', description: 'Defaults to 1. 25 items per page.' }, }, }), responses: { ...response200( 'Retrieves the ships currently being built at this shipyard.', shipsBuildingSchema ), ...response500(), }, }, }, [`${base}/subsidize_build_queue`]: { post: { ...tags(base), ...security(), ...operation( 'Subsidize build queue.', 'Completes the entire build queue immediately for 1 essentia per ship. Throws 1011.' ), ...buildingIdRequestBody, responses: { ...response200( 'Completes the entire build queue immediately for 1 essentia per ship. Throws 1011.', shipsBuildingSchema ), ...response500(), }, }, }, [`${base}/subsidize_ship`]: { post: { ...tags(base), ...security(), ...operation( 'Subsidize ship.', 'Completes a single ship immediately for 1 essentia. Throws 1011.' ), ...requestBodySchema({ type: 'object', required: ['building_id', 'ship_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, ship_id: { type: 'integer', description: 'The unique id of the ship.' }, }, }), responses: { ...response200( 'Completes a single ship immediately for 1 essentia. Throws 1011.', shipsBuildingSchema ), ...response500(), }, }, }, [`${base}/get_buildable`]: { post: { ...tags(base), ...security(), ...operation('Get buildable.', 'Lists buildable ship types with cost and availability.'), ...requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, tag: { type: 'string', enum: ['Trade', 'Colonization', 'Intelligence', 'Exploration', 'War', 'Mining'], description: 'Optional tag to limit which ship types are listed.', }, }, }), responses: { ...response200('Lists buildable ship types with cost and availability.', { type: 'object', required: [ 'buildable', 'docks_available', 'build_queue_max', 'build_queue_used', 'status', ], properties: { buildable: { type: 'object', description: 'Keyed by ship type.', additionalProperties: { type: 'object', required: ['can', 'cost', 'attributes'], properties: { can: { type: 'boolean' }, reason: { type: 'array', items: {} }, cost: { type: 'object', properties: { seconds: { type: 'integer' }, food: { type: 'integer' }, water: { type: 'integer' }, energy: { type: 'integer' }, ore: { type: 'integer' }, waste: { type: 'integer' }, }, }, attributes: { type: 'object', properties: { speed: { type: 'integer' }, hold_size: { type: 'integer' }, max_occupants: { type: 'integer' }, combat: { type: 'integer' }, stealth: { type: 'integer' }, }, }, }, }, }, docks_available: { type: 'integer' }, build_queue_max: { type: 'integer' }, build_queue_used: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/build_ship`]: { post: { ...tags(base), ...security(), ...operation('Build ship.', 'Queues ships for construction at this shipyard.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'type'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, type: { type: 'string', description: 'A ship type, from get_buildable.' }, quantity: { type: 'integer', minimum: 1, maximum: 600, description: 'Number of ships to build, up to 600. Defaults to 1.', }, }, }), responses: { ...response200('Queues ships for construction at this shipyard.', shipsBuildingSchema), ...response500(), }, }, }, [`${base}/build_ships`]: { post: { ...tags(base), ...security(), ...operation( 'Build ships.', 'Queues ships for construction across multiple shipyards at once.' ), ...requestBodySchema({ type: 'object', required: ['options'], properties: { options: { type: 'object', description: 'Build options selecting ship type, quantity, and which shipyards to use.', required: ['type'], properties: { type: { type: 'string', description: 'A ship type, from get_buildable.' }, quantity: { type: 'integer', minimum: 1, maximum: 600, description: 'Defaults to 1.', }, body_id: { type: 'integer', description: 'Alternative to building_id.' }, building_id: { description: 'A single shipyard id, or an array of shipyard ids.', oneOf: [{ type: 'integer' }, { type: 'array', items: { type: 'integer' } }], }, autoselect: { type: 'string', enum: ['all', 'higher', 'only'], description: 'Shipyard autoselect mode. Defaults to using only the shipyard(s) in building_id.', }, }, }, }, }), responses: { ...response200('Queues ships for construction across multiple shipyards at once.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, };