import { operation, buildingBase, buildingCommonMethods, buildingView, requestBodySchema, response200, response500, security, statusSchema, tags, } from '../../chunks.ts'; const base = buildingBase('Intelligence'); const buildingIdRequestBody = requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' } }, }); const ASSIGNMENTS = [ 'Idle', 'Bugout', 'Counter Espionage', 'Security Sweep', 'Intel Training', 'Mayhem Training', 'Politics Training', 'Theft Training', 'Political Propaganda', 'Gather Resource Intelligence', 'Gather Empire Intelligence', 'Gather Operative Intelligence', 'Hack Network 19', 'Sabotage Probes', 'Rescue Comrades', 'Sabotage Resources', 'Appropriate Resources', 'Assassinate Operatives', 'Sabotage Infrastructure', 'Sabotage Defenses', 'Sabotage BHG', 'Incite Mutiny', 'Abduct Operatives', 'Appropriate Technology', 'Incite Rebellion', 'Incite Insurrection', ]; const spySchema = { type: 'object', required: [ 'id', 'name', 'assignment', 'level', 'politics', 'mayhem', 'theft', 'intel', 'is_available', ], properties: { id: { type: 'integer' }, name: { type: 'string' }, assignment: { type: 'string', enum: ASSIGNMENTS }, possible_assignments: { type: 'array', items: { type: 'object', properties: { task: { type: 'string', enum: ASSIGNMENTS }, recovery: { type: 'integer' }, skill: { type: 'string' }, }, }, }, level: { type: 'integer' }, politics: { type: 'integer' }, mayhem: { type: 'integer' }, theft: { type: 'integer' }, intel: { type: 'integer' }, offense_rating: { type: 'integer' }, defense_rating: { type: 'integer' }, assigned_to: { type: 'object', properties: { body_id: { type: 'integer' }, name: { type: 'string' }, x: { type: 'integer' }, y: { type: 'integer' }, }, }, based_from: { type: 'object', properties: { body_id: { type: 'integer' }, name: { type: 'string' }, x: { type: 'integer' }, y: { type: 'integer' }, }, }, is_available: { type: 'integer', enum: [1, 0] }, available_on: { type: 'string' }, started_assignment: { type: 'string' }, seconds_remaining: { type: 'integer' }, mission_count: { type: 'object', properties: { offensive: { type: 'integer' }, defensive: { type: 'integer' } }, }, }, }; export const intelligence = { ...buildingCommonMethods(base), ...buildingView(base, { spies: { type: 'object', properties: { maximum: { type: 'integer' }, current: { type: 'integer' }, in_training: { type: 'integer' }, training_costs: { $ref: '#/components/schemas/building_cost' }, }, }, }), [`${base}/train_spy`]: { post: { ...tags(base), ...security(), ...operation('Train spy.', 'Queues spies for training. Throws 1013, 1009.'), ...requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, quantity: { type: 'integer', minimum: 1, maximum: 5, description: 'Defaults to 1.' }, }, }), responses: { ...response200('Queues spies for training. Throws 1013, 1009.', { type: 'object', required: ['trained', 'not_trained', 'status'], properties: { trained: { type: 'integer' }, not_trained: { type: 'integer' }, reason_not_trained: { type: 'object', properties: { code: { type: 'integer' }, message: { type: 'string' } }, }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/view_spies`]: { post: { ...tags(base), ...security(), ...operation('View spies.', 'Retrieves a paginated spy roster.'), ...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. 30 per page.' }, }, }), responses: { ...response200('Retrieves a paginated spy roster.', { type: 'object', required: ['spies', 'spy_count', 'status'], properties: { spies: { type: 'array', items: spySchema }, spy_count: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/view_all_spies`]: { post: { ...tags(base), ...security(), ...operation('View all spies.', 'Retrieves the complete (non-paginated) spy roster.'), ...buildingIdRequestBody, responses: { ...response200('Retrieves the complete (non-paginated) spy roster.', { type: 'object', required: ['spies', 'spy_count', 'status'], properties: { spies: { type: 'array', items: spySchema }, spy_count: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/subsidize_training`]: { post: { ...tags(base), ...security(), ...operation( 'Subsidize training.', 'Completes all in-training spies immediately for 1 essentia per spy. Returns the building view. Throws 1011.' ), ...buildingIdRequestBody, responses: { ...response200( 'Completes all in-training spies immediately for 1 essentia per spy. Returns the building view. Throws 1011.', { type: 'object', required: ['building', 'status'], properties: { building: { $ref: '#/components/schemas/building' }, status: statusSchema(), }, } ), ...response500(), }, }, }, [`${base}/burn_spy`]: { post: { ...tags(base), ...security(), ...operation('Burn spy.', 'Eliminates a spy from payroll. Throws 1002, 1010.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'spy_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, spy_id: { type: 'integer', description: 'The unique id of the spy.' }, }, }), responses: { ...response200('Eliminates a spy from payroll. Throws 1002, 1010.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, [`${base}/name_spy`]: { post: { ...tags(base), ...security(), ...operation('Name spy.', "Sets a spy's name. Throws 1002, 1005, 1013."), ...requestBodySchema({ type: 'object', required: ['building_id', 'spy_id', 'name'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, spy_id: { type: 'integer', description: 'The unique id of the spy.' }, name: { type: 'string', description: 'Cannot contain @, <, #, &, ; or profanity.' }, }, }), responses: { ...response200("Sets a spy's name. Throws 1002, 1005, 1013.", { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, [`${base}/name_spies`]: { post: { ...tags(base), ...security(), ...operation('Name spies.', 'Batch-names spies using the pattern "prefix ## suffix".'), ...requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, prefix: { type: 'string', description: 'Optional name prefix. New names look like "prefix ## suffix".', }, suffix: { type: 'string', description: 'Optional name suffix.' }, rename_null_only: { type: 'boolean', description: 'When true, only renames spies still named "Agent Null".', }, }, }), responses: { ...response200('Batch-names spies using the pattern "prefix ## suffix".', { type: 'object', required: ['spies', 'spy_count', 'renamed', 'status'], properties: { spies: { type: 'array', items: spySchema }, spy_count: { type: 'integer' }, renamed: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/assign_spy`]: { post: { ...tags(base), ...security(), ...operation('Assign spy.', 'Assigns a spy to a new task.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'spy_id', 'assignment'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, spy_id: { type: 'integer', description: 'The unique id of the spy.' }, assignment: { oneOf: [ { type: 'string', enum: ASSIGNMENTS }, { type: 'object', required: ['assignment'], properties: { assignment: { type: 'string', enum: ASSIGNMENTS }, noempty: { type: 'boolean', description: 'For Security Sweep: suppress the email sent when no spies are found.', }, }, }, ], }, }, }), responses: { ...response200('Assigns a spy to a new task.', { type: 'object', required: ['mission', 'spy', 'status'], properties: { mission: { type: 'object', properties: { result: { type: 'string', enum: ['Accepted', 'Success', 'Bounce', 'Failure'] }, message_id: { type: 'integer' }, reason: { type: 'string' }, }, }, spy: spySchema, status: statusSchema(), }, }), ...response500(), }, }, }, };