import { operation, buildingBase, requestBodySchema, response200, response500, security, statusSchema, tags, } from '../../chunks.ts'; const base = buildingBase('PoliceStation'); const buildingIdRequestBody = requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' } }, }); const pagedRequestBody = (extraRequired: string[] = [], extraProperties: object = {}) => requestBodySchema({ type: 'object', required: ['building_id', ...extraRequired], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, page_number: { type: 'integer', description: 'Defaults to 1. Each page contains 25 results.', }, ...extraProperties, }, }); const shipSchema = { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, type: { type: 'string' }, type_human: { type: 'string' }, date_arrives: { type: 'string' }, date_arrived: { type: 'string' }, from: { type: 'object', description: "Only included if the ship's stealth is low enough relative to the Police Station's level.", properties: { id: { type: 'integer' }, name: { type: 'string' }, empire: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' } }, }, }, }, }, }; // PoliceStation.pod: "captured spies are detained at the Police Station." Its .pod header refers // to it as extending Buildings, but per Modules.pod, PoliceStation is a module and does not // inherit build/upgrade/downgrade/demolish/repair. export const policeStation = { [`${base}/view`]: { post: { ...tags(base), ...security(), ...operation( "Retrieve this module's properties.", 'Retrieves the properties of this module.' ), ...buildingIdRequestBody, responses: { ...response200('Retrieves the properties of this module.', { type: 'object', required: ['building', 'status'], properties: { building: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, image: { type: 'string' }, level: { type: 'integer' }, x: { type: 'integer' }, y: { type: 'integer' }, efficiency: { type: 'integer' }, }, required: ['id', 'name', 'image', 'level', 'x', 'y', 'efficiency'], }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/view_prisoners`]: { post: { ...tags(base), ...security(), ...operation('View prisoners.', 'Displays a list of the spies that have been captured.'), ...pagedRequestBody(), responses: { ...response200('Displays a list of the spies that have been captured.', { type: 'object', required: ['prisoners', 'status', 'captured_count'], properties: { captured_count: { type: 'integer', description: 'Total captured spies across all pages (the pager is sized from this).', }, prisoners: { type: 'array', items: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, level: { type: 'integer' }, task: { type: 'string', enum: ['Captured', 'Prisoner Transport'] }, sentence_expires: { type: 'string' }, }, }, }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/execute_prisoner`]: { post: { ...tags(base), ...security(), ...operation( 'Execute prisoner.', 'Executes a captured prisoner rather than letting them serve their sentence.' ), ...requestBodySchema({ type: 'object', required: ['building_id', 'prisoner_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, prisoner_id: { type: 'integer', description: 'The unique id of a captured prisoner. See view_prisoners.', }, }, }), responses: { ...response200( 'Executes a captured prisoner rather than letting them serve their sentence.', { type: 'object', required: ['status'], properties: { status: statusSchema() } } ), ...response500(), }, }, }, [`${base}/release_prisoner`]: { post: { ...tags(base), ...security(), ...operation('Release prisoner.', 'Releases a captured prisoner.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'prisoner_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, prisoner_id: { type: 'integer', description: 'The unique id of a captured prisoner. See view_prisoners.', }, }, }), responses: { ...response200('Releases a captured prisoner.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, [`${base}/view_foreign_spies`]: { post: { ...tags(base), ...security(), ...operation( 'View foreign spies.', 'Displays a list of the spies on your planet with a level lower than your Police Station.' ), ...pagedRequestBody(), responses: { ...response200( 'Displays a list of the spies on your planet with a level lower than your Police Station.', { type: 'object', required: ['spies', 'status', 'spy_count'], properties: { spy_count: { type: 'integer', description: 'Total foreign spies across all pages (the pager is sized from this).', }, spies: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, level: { type: 'integer' }, task: { type: 'string' }, next_mission: { type: 'string' }, }, }, }, status: statusSchema(), }, } ), ...response500(), }, }, }, [`${base}/view_foreign_ships`]: { post: { ...tags(base), ...security(), ...operation( 'View foreign ships.', "Shows incoming foreign ships filtered by the ship's stealth vs the Police Station's level (525 * level >= stealth to be visible at all; the `from` block requires 675 * level >= stealth)." ), ...pagedRequestBody(), responses: { ...response200( "Shows incoming foreign ships filtered by the ship's stealth vs the Police Station's level (525 * level >= stealth to be visible at all; the `from` block requires 675 * level >= stealth).", { type: 'object', required: ['ships', 'number_of_ships', 'status'], properties: { ships: { type: 'array', items: shipSchema }, number_of_ships: { type: 'integer' }, status: statusSchema(), }, } ), ...response500(), }, }, }, [`${base}/view_ships_travelling`]: { post: { ...tags(base), ...security(), ...operation( 'View ships travelling.', 'Returns a list of ships travelling to or from this planet, regardless of destination space port.' ), ...pagedRequestBody(), responses: { ...response200( 'Returns a list of ships travelling to or from this planet, regardless of destination space port.', { type: 'object', required: ['ships_travelling', 'number_of_ships_travelling', 'status'], properties: { ships_travelling: { type: 'array', items: { type: 'object', properties: { id: { type: 'integer' }, type: { type: 'string' }, type_human: { type: 'string' }, date_arrives: { type: 'string' }, from: { type: 'object', properties: { id: { type: 'integer' }, type: { type: 'string' }, name: { type: 'string' }, }, }, to: { type: 'object', properties: { id: { type: 'integer' }, type: { type: 'string' }, name: { type: 'string' }, }, }, }, }, }, number_of_ships_travelling: { type: 'integer' }, status: statusSchema(), }, } ), ...response500(), }, }, }, [`${base}/view_ships_orbiting`]: { post: { ...tags(base), ...security(), ...operation( 'View ships orbiting.', "Shows foreign ships orbiting this planet, filtered by the ship's stealth vs the Police Station's level (525 * level >= stealth to be visible at all; the `from` block requires 675 * level >= stealth)." ), ...pagedRequestBody(), responses: { ...response200( "Shows foreign ships orbiting this planet, filtered by the ship's stealth vs the Police Station's level (525 * level >= stealth to be visible at all; the `from` block requires 675 * level >= stealth).", { type: 'object', required: ['ships', 'number_of_ships', 'status'], properties: { ships: { type: 'array', items: shipSchema }, number_of_ships: { type: 'integer' }, status: statusSchema(), }, } ), ...response500(), }, }, }, };