From 24fe324075208544d22a4638be29e7b4a6c0ed05 Mon Sep 17 00:00:00 2001 From: Natalie Rose Date: Mon, 17 Aug 2026 11:10:32 +1000 Subject: [PATCH] Add missing empire methods --- src/spec/chunks.ts | 40 ++++++++ src/spec/paths/empire.ts | 207 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 242 insertions(+), 5 deletions(-) diff --git a/src/spec/chunks.ts b/src/spec/chunks.ts index f16d201..d1a67f5 100644 --- a/src/spec/chunks.ts +++ b/src/spec/chunks.ts @@ -49,3 +49,43 @@ export const statusSchema = () => { required: ['server'], }; }; + +export const speciesSchema = () => { + return { + type: 'object', + required: [ + 'name', + 'description', + 'min_orbit', + 'max_orbit', + 'manufacturing_affinity', + 'deception_affinity', + 'research_affinity', + 'management_affinity', + 'farming_affinity', + 'mining_affinity', + 'science_affinity', + 'environmental_affinity', + 'political_affinity', + 'trade_affinity', + 'growth_affinity', + ], + properties: { + name: { type: 'string' }, + description: { type: 'string' }, + min_orbit: { type: 'integer', minimum: 1, maximum: 7 }, + max_orbit: { type: 'integer', minimum: 1, maximum: 7 }, + manufacturing_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + deception_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + research_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + management_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + farming_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + mining_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + science_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + environmental_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + political_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + trade_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + growth_affinity: { type: 'integer', minimum: 1, maximum: 7 }, + }, + }; +}; diff --git a/src/spec/paths/empire.ts b/src/spec/paths/empire.ts index f9a3222..f49e3d4 100644 --- a/src/spec/paths/empire.ts +++ b/src/spec/paths/empire.ts @@ -1,4 +1,11 @@ -import { requestBodySchema, response200, response500, security, statusSchema } from '../chunks'; +import { + requestBodySchema, + response200, + response500, + security, + speciesSchema, + statusSchema, +} from '../chunks'; export const empire = { '/v2/empire/is_name_available': { @@ -239,7 +246,8 @@ export const empire = { name: { type: 'string' }, image: { type: 'string' }, date: { type: 'string', format: 'date-time' }, - public: { type: 'integer', enum: [1, 0], times_earned: { type: 'integer' } }, + public: { type: 'integer', enum: [1, 0] }, + times_earned: { type: 'integer' }, }, }, city: { type: 'string' }, @@ -263,8 +271,8 @@ export const empire = { email: { type: 'string', format: 'email' }, sitter_password: { type: 'string' }, }, - status: statusSchema(), }, + status: statusSchema(), }, } ), @@ -319,7 +327,8 @@ export const empire = { name: { type: 'string' }, image: { type: 'string' }, date: { type: 'string', format: 'date-time' }, - public: { type: 'integer', enum: [1, 0], times_earned: { type: 'integer' } }, + public: { type: 'integer', enum: [1, 0] }, + times_earned: { type: 'integer' }, }, }, city: { type: 'string' }, @@ -343,8 +352,8 @@ export const empire = { email: { type: 'string', format: 'email' }, sitter_password: { type: 'string' }, }, - status: statusSchema(), }, + status: statusSchema(), }, } ), @@ -969,4 +978,192 @@ export const empire = { }), }, }, + + '/v2/empire/update_species': { + post: { + ...security(), + + responses: { + ...response200( + "Updates the species definition for an empire that hasn't been founded yet. Returns 1.", + { type: 'integer', enum: [1] } + ), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['empire_id', 'params'], + properties: { empire_id: { type: 'string' }, params: speciesSchema() }, + }), + }, + }, + + '/v2/empire/redefine_species_limits': { + post: { + ...security(), + + responses: { + ...response200( + 'Returns the limits that apply if the empire wants to redefine its species.', + { + type: 'object', + required: ['essentia_cost', 'max_orbit', 'min_orbit', 'min_growth', 'can', 'status'], + properties: { + essentia_cost: { type: 'integer' }, + max_orbit: { type: 'integer' }, + min_orbit: { type: 'integer' }, + min_growth: { type: 'integer' }, + can: { type: 'integer', enum: [1, 0] }, + reason: { type: 'string' }, + status: statusSchema(), + }, + } + ), + ...response500(), + }, + }, + }, + + '/v2/empire/redefine_species': { + post: { + ...security(), + + responses: { + ...response200('Redefines the species of an already-founded empire.', { + type: 'object', + required: ['status'], + properties: { status: statusSchema() }, + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['params'], + properties: { params: speciesSchema() }, + }), + }, + }, + + '/v2/empire/view_species_stats': { + post: { + ...security(), + + responses: { + ...response200("Returns the empire's original species attributes.", { + type: 'object', + required: ['species', 'status'], + properties: { species: speciesSchema(), status: statusSchema() }, + }), + ...response500(), + }, + }, + }, + + '/v2/empire/get_species_templates': { + post: { + responses: { + ...response200( + 'Returns the list of pre-defined species templates available when founding an empire.', + { type: 'array', items: speciesSchema() } + ), + ...response500(), + }, + }, + }, + + '/v2/empire/view_authorized_sitters': { + post: { + ...security(), + + responses: { + ...response200('Lists the empires currently authorized to sit for this empire.', { + type: 'object', + required: ['sitters', 'status'], + properties: { + sitters: { + type: 'array', + items: { + type: 'object', + required: ['id', 'name', 'expiry'], + properties: { + id: { type: 'integer' }, + name: { type: 'string' }, + expiry: { type: 'string', format: 'date-time' }, + }, + }, + }, + status: statusSchema(), + }, + }), + ...response500(), + }, + }, + }, + + '/v2/empire/authorize_sitters': { + post: { + ...security(), + + responses: { + ...response200('Authorizes one or more empires (or an alliance) to sit for this empire.', { + type: 'object', + required: ['auths', 'status'], + properties: { + auths: { + type: 'array', + items: { + type: 'object', + required: ['id', 'name'], + properties: { id: { type: 'integer' }, name: { type: 'string' } }, + }, + }, + rejected_ids: { + type: 'array', + items: { + type: 'object', + required: ['id', 'reason'], + properties: { id: { type: 'string' }, reason: { type: 'string' } }, + }, + }, + status: statusSchema(), + }, + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + properties: { + allied: { type: 'integer', enum: [1, 0] }, + alliance: { type: 'string' }, + alliance_id: { type: 'string' }, + empires: { type: 'array', items: { type: 'string' } }, + revalidate_all: { type: 'integer', enum: [1, 0] }, + }, + }), + }, + }, + + '/v2/empire/deauthorize_sitters': { + post: { + ...security(), + + responses: { + ...response200('Removes sitting authorization from one or more empires.', { + type: 'object', + required: ['status'], + properties: { status: statusSchema() }, + }), + ...response500(), + }, + + ...requestBodySchema({ + type: 'object', + required: ['empires'], + properties: { empires: { type: 'array', items: { type: 'string' } } }, + }), + }, + }, }; -- 2.51.2