import { operation, requestBodySchema, response200, response500, security, statusSchema, tags, } from '../chunks.ts'; export const body = { '/v2/body/get_status': { post: { ...tags('body'), ...security(), ...operation( 'Get detailed status for a body.', 'Returns detailed statistics about a body owned or sat for by the current empire. You should probably never call this directly — the same data comes back in the status block of every relevant request.' ), ...requestBodySchema({ type: 'object', required: ['body_id'], properties: { body_id: { type: 'integer', description: 'The id of the body you wish to retrieve.' }, }, }), responses: { ...response200( 'Returns information about the current state of this body. Must be owned or a sitter of the current empire.', { type: 'object', required: ['empire', 'body'], properties: { server: { $ref: '#/components/schemas/server_status' }, empire: { $ref: '#/components/schemas/empire_status' }, body: { $ref: '#/components/schemas/body_status' }, }, } ), ...response500(), }, }, }, '/v2/body/get_body_status': { post: { ...tags('body'), ...security(), ...operation( 'Get the public star-map status for a body.', 'Returns the public star-map view of any body. This endpoint is not part of the original API documentation.' ), ...requestBodySchema({ type: 'object', required: ['body_id'], properties: { body_id: { type: 'integer', description: 'The id of the body you wish to retrieve.' }, }, }), responses: { ...response200('Usd in the Star Map. Returns public information about the given body.', { type: 'object', required: ['body'], properties: { body: { $ref: '#/components/schemas/body_status' }, status: statusSchema(), }, }), ...response500(), }, }, }, '/v2/body/get_buildings': { post: { ...tags('body'), ...security(), ...operation( 'List the buildings on a body.', 'Retrieves the buildings on a body. The surface is an 11x11 tile grid running from -5 to 5 on both axes, with the Planetary Command Center always at 0,0; fill the remaining tiles with blank ground. Throws 1002 and 1010.' ), ...requestBodySchema({ type: 'object', required: ['body_id'], properties: { body_id: { type: 'integer', description: 'The id of the body you wish to retrieve the buildings on.', }, }, }), responses: { ...response200( "Retrieves the buildings on a planet's 11x11 (-5 to 5) surface grid. The planetary command building is always at 0,0.", { type: 'object', required: ['buildings', 'body', 'status'], properties: { buildings: { $ref: '#/components/schemas/buildings_list' }, body: { type: 'object', required: ['surface_image'], properties: { surface_image: { type: 'string' } }, }, status: statusSchema(), }, } ), ...response500(), }, }, }, '/v2/body/get_buildings_resources': { post: { ...tags('body'), ...security(), ...operation( "List buildings on a body with each one's resource contribution.", "Like get_buildings, but every building entry additionally carries a `resources` object describing that building's hourly production/consumption and storage capacity for each resource, plus per-food-type and per-ore-type breakdowns. Throws 1002 and 1010." ), ...requestBodySchema({ type: 'object', required: ['body_id'], properties: { body_id: { type: 'integer', description: 'The id of the body you wish to retrieve the buildings on.', }, }, }), responses: { ...response200( 'Like get_buildings, but every building entry additionally carries a `resources` object: hourly production/consumption and storage capacity for food/ore/water/waste/energy plus happiness_hour, and per-food-type / per-ore-type production breakdowns (each omitted when the building produces none of that resource).', { type: 'object', required: ['buildings', 'body', 'status'], properties: { buildings: { $ref: '#/components/schemas/buildings_resources_list' }, body: { type: 'object', required: ['surface_image'], properties: { surface_image: { type: 'string' } }, }, status: statusSchema(), }, } ), ...response500(), }, }, }, '/v2/body/repair_list': { post: { ...tags('body'), ...security(), ...operation( 'Repair a list of buildings.', 'Repairs the given buildings, in the order their ids are supplied. Returns the same shape as get_buildings, but only for the repaired buildings.' ), ...requestBodySchema({ type: 'object', required: ['body_id', 'building_ids'], properties: { body_id: { type: 'integer', description: 'The id of the body the buildings are on.' }, building_ids: { type: 'array', items: { type: 'integer' }, description: 'The building ids to repair, in the order they should be repaired.', }, }, }), responses: { ...response200( 'Repairs the given buildings, in the order provided. Returns the same shape as get_buildings, but only for the repaired buildings.', { type: 'object', required: ['buildings', 'body', 'status'], properties: { buildings: { $ref: '#/components/schemas/buildings_list' }, body: { type: 'object', required: ['surface_image'], properties: { surface_image: { type: 'string' } }, }, status: statusSchema(), }, } ), ...response500(), }, }, }, '/v2/body/rearrange_buildings': { post: { ...tags('body'), ...security(), ...operation( 'Move buildings to new coordinates.', 'Rearranges buildings to the coordinates supplied in the arrangement array. Throws 1002 and 1010.' ), ...requestBodySchema({ type: 'object', required: ['body_id', 'arrangement'], properties: { body_id: { type: 'integer', description: 'The id of the body you wish to arrange buildings on.', }, arrangement: { type: 'array', description: 'Every building being moved must be included. The Planetary Command/Station Command must end up at 0,0.', items: { type: 'object', required: ['id', 'x', 'y'], properties: { id: { type: 'integer', description: 'The id of the building to move.' }, x: { type: 'integer', minimum: -5, maximum: 5, description: 'The new x coordinate for the building.', }, y: { type: 'integer', minimum: -5, maximum: 5, description: 'The new y coordinate for the building.', }, }, }, }, }, }), responses: { ...response200('Rearranges buildings to the supplied coordinates.', { type: 'object', required: ['moved', 'body', 'status'], properties: { moved: { type: 'array', items: { type: 'object', required: ['id', 'name', 'x', 'y'], properties: { id: { type: 'integer' }, name: { type: 'string' }, x: { type: 'integer' }, y: { type: 'integer' }, }, }, }, body: { type: 'object', required: ['surface_image'], properties: { surface_image: { type: 'string' } }, }, status: statusSchema(), }, }), ...response500(), }, }, }, '/v2/body/get_buildable': { post: { ...tags('body'), ...security(), ...operation( 'List building types buildable on a tile.', 'Lists every building type that can be built on the given tile and matches the given tag. If several plans apply, returns the one with the highest extra_build_level. Throws 1002, 1010, 1011, 1012, and 1013.' ), ...requestBodySchema({ type: 'object', required: ['body_id', 'x', 'y', 'tag'], properties: { body_id: { type: 'integer', description: 'The id of the body you wish to build on.' }, x: { type: 'integer', minimum: -5, maximum: 5, description: 'The x axis of the tile on the planet surface. Valid values are between -5 and 5 inclusive.', }, y: { type: 'integer', minimum: -5, maximum: 5, description: 'The y axis of the tile on the planet surface. Valid values are between -5 and 5 inclusive.', }, tag: { type: 'string', description: 'A tag that limits which building types are returned. Required. Cannot be Now, Soon, or Later; all other tags are allowed.', }, }, }), responses: { ...response200( 'Lists the building types buildable at a given spot for a given tag. If multiple plans apply, returns the one with the highest extra_build_level.', { type: 'object', required: ['max_items_in_build_queue', 'build_queue', 'buildable', 'status'], properties: { max_items_in_build_queue: { type: 'integer' }, build_queue: { type: 'object', required: ['max', 'current'], properties: { max: { type: 'integer' }, current: { type: 'integer' } }, }, buildable: { type: 'object', description: 'Keyed by building type name.', additionalProperties: { type: 'object', required: ['url', 'build', 'image', 'production'], properties: { url: { type: 'string' }, image: { type: 'string' }, build: { type: 'object', required: ['can', 'no_plot_use', 'cost', 'tags', 'reason'], properties: { can: { type: 'integer', enum: [1, 0] }, no_plot_use: { type: 'integer', enum: [1, 0] }, cost: { $ref: '#/components/schemas/building_cost' }, // Only present for some plan types — skips level 1 and builds straight // to this level. extra_level: { type: 'integer' }, tags: { type: 'array', items: { type: 'string' } }, reason: { type: 'array', items: {}, description: '[code, message, data], same shape as an rpc_error.', }, }, }, production: { type: 'object', properties: { food_hour: { type: 'integer' }, energy_hour: { type: 'integer' }, ore_hour: { type: 'integer' }, water_hour: { type: 'integer' }, waste_hour: { type: 'integer' }, happiness_hour: { type: 'integer' }, }, }, }, }, }, status: statusSchema(), }, } ), ...response500(), }, }, }, '/v2/body/get_buildable_locations': { post: { ...tags('body'), ...security(), ...operation( 'List unoccupied buildable locations.', 'Tells you where buildings can be placed on the body. The order of the returned list is not guaranteed.' ), ...requestBodySchema({ type: 'object', required: ['body_id'], properties: { body_id: { type: 'integer', description: 'The id of the body you wish to get the free locations of.', }, size: { type: 'integer', description: 'Optional building footprint size. 9 = center tile (LCOT), 4 = northwest tile (SSLA); omitted/other values return locations for single-tile buildings.', }, }, }), responses: { ...response200( 'Lists unoccupied buildable locations on the planet. Order is not guaranteed.', { type: 'object', required: ['unoccupied', 'status'], properties: { unoccupied: { type: 'array', items: { type: 'array', items: { type: 'integer' }, minItems: 2, maxItems: 2 }, }, status: statusSchema(), }, } ), ...response500(), }, }, }, '/v2/body/rename': { post: { ...tags('body'), ...security(), ...operation( 'Rename a body.', 'Renames a body owned by the empire attached to this session. Throws 1000, 1002, and 1010.' ), ...requestBodySchema({ type: 'object', required: ['body_id', 'name'], properties: { body_id: { type: 'integer', description: 'The id of the body you wish to rename.' }, name: { type: 'string', description: 'The new name for the body.' }, }, }), responses: { ...response200('Renames a body owned by the empire attached to this session.', { type: 'integer', enum: [1], }), ...response500(), }, }, }, '/v2/body/abandon': { post: { ...tags('body'), ...security(), ...operation( 'Abandon a colony.', 'Abandons a colony, destroying everything on the planet. You cannot abandon your home planet.' ), ...requestBodySchema({ type: 'object', required: ['body_id'], properties: { body_id: { type: 'integer', description: 'The unique id of the colony you wish to abandon. You cannot abandon your home planet.', }, }, }), responses: { ...response200( 'Abandons a colony, destroying everything on the planet. The home planet cannot be abandoned.', { type: 'object', required: ['status'], properties: { status: statusSchema() } } ), ...response500(), }, }, }, '/v2/body/view_laws': { post: { ...tags('body'), ...security(), ...operation( 'View the laws of a space station.', 'Returns the laws enacted by this space station. Pass the id of the station itself, not its Parliament building, since anyone may view the laws in a jurisdiction.' ), ...requestBodySchema({ type: 'object', required: ['body_id'], properties: { body_id: { type: 'integer', description: 'The id of the space station itself, not its Parliament building.', }, }, }), responses: { ...response200('Returns the laws enacted by this space station.', { type: 'object', required: ['status', 'laws'], properties: { status: statusSchema(), laws: { type: 'array', items: { type: 'object', required: ['id', 'name', 'description', 'date_enacted'], properties: { id: { type: 'integer' }, name: { type: 'string' }, description: { type: 'string' }, date_enacted: { type: 'string' }, }, }, }, }, }), ...response500(), }, }, }, '/v2/body/set_colony_notes': { post: { ...tags('body'), ...security(), ...operation( 'Set the notes for a colony.', 'Sets the per-colony notes for an owned body (colony or station).' ), ...requestBodySchema({ type: 'object', required: ['body_id', 'options'], properties: { body_id: { type: 'integer', description: 'The unique id of the body whose notes you want to update.', }, options: { type: 'object', description: 'A hash of options. Currently the only valid key is `notes`.', required: ['notes'], properties: { notes: { type: 'string', description: 'The notes to assign to the body.' }, }, }, }, }), responses: { ...response200('Sets the per-colony notes for an owned body (colony or station).', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, };