import { operation, buildingBase, buildingCommonMethods, buildingView, requestBodySchema, response200, response500, security, statusSchema, tags, } from '../../chunks.ts'; const base = buildingBase('Transporter'); const buildingIdRequestBody = requestBodySchema({ type: 'object', required: ['building_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' } }, }); // A tradeable/pushable item — resources (name/quantity), glyphs, plans, prisoners, or ships. const tradeableItemSchema = { type: 'object', properties: { type: { type: 'string', enum: ['glyph', 'plan', 'prisoner', 'ship'] }, // Resources are passed as { type: , quantity }. name: { type: 'string' }, quantity: { type: 'integer' }, glyph_id: { type: 'integer' }, plan_id: { type: 'integer' }, prisoner_id: { type: 'integer' }, ship_id: { type: 'integer' }, }, }; const marketEntrySchema = { type: 'object', required: ['id', 'date_offered', 'ask', 'offer'], properties: { id: { type: 'integer' }, date_offered: { type: 'string' }, ask: { type: 'number', description: 'Essentia amount requested.' }, offer: { type: 'array', items: { type: 'string' }, description: 'Human-readable descriptions of the offered items.', }, empire: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' } } }, }, }; export const transporter = { ...buildingCommonMethods(base), ...buildingView(base, { transport: { type: 'object', properties: { max: { type: 'integer' }, pushable: { type: 'array', description: 'Planets with currently-online Transporters, alphabetical by name.', items: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, x: { type: 'integer' }, y: { type: 'integer' }, zone: { type: 'string' }, }, }, }, }, }, }), [`${base}/add_to_market`]: { post: { ...tags(base), ...security(), ...operation( 'Add to market.', 'Queues a trade for other players to see. Costs 1 essentia in addition to whatever is offered.' ), ...requestBodySchema({ type: 'object', required: ['building_id', 'offer', 'ask'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, offer: { type: 'array', items: tradeableItemSchema, description: 'Resources, glyphs, plans, prisoners, or ships to offer.', }, ask: { type: 'number', minimum: 0.1, maximum: 100, description: 'Essentia amount requested.', }, }, }), responses: { ...response200( 'Queues a trade for other players to see. Costs 1 essentia in addition to whatever is offered.', { type: 'object', required: ['trade_id', 'status'], properties: { trade_id: { type: 'integer' }, status: statusSchema() }, } ), ...response500(), }, }, }, [`${base}/get_ships`]: { post: { ...tags(base), ...security(), ...operation('Get ships.', 'Lists ships that may be traded. Used with add_to_market.'), ...buildingIdRequestBody, responses: { ...response200('Lists ships that may be traded. Used with add_to_market.', { type: 'object', required: ['ships', 'cargo_space_used_each', 'status'], properties: { ships: { type: 'array', items: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, type: { type: 'string' }, hold_size: { type: 'integer' }, speed: { type: 'integer' }, }, }, }, cargo_space_used_each: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/get_prisoners`]: { post: { ...tags(base), ...security(), ...operation( 'Get prisoners.', 'Lists prisoners that may be traded. Used with add_to_market.' ), ...buildingIdRequestBody, responses: { ...response200('Lists prisoners that may be traded. Used with add_to_market.', { type: 'object', required: ['prisoners', 'cargo_space_used_each', 'status'], properties: { prisoners: { type: 'array', items: { type: 'object', properties: { id: { type: 'integer' }, name: { type: 'string' }, level: { type: 'integer' }, sentence_expires: { type: 'string' }, }, }, }, cargo_space_used_each: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/get_plan_summary`]: { post: { ...tags(base), ...security(), ...operation( 'Get plan summary.', 'Lists plans that may be traded, in summary form. Used with add_to_market.' ), ...buildingIdRequestBody, responses: { ...response200( 'Lists plans that may be traded, in summary form. Used with add_to_market.', { type: 'object', required: ['plans', 'cargo_space_used_each', 'status'], properties: { plans: { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, level: { type: 'integer' }, extra_build_level: { type: 'integer' }, quantity: { type: 'integer' }, }, }, }, cargo_space_used_each: { type: 'integer' }, status: statusSchema(), }, } ), ...response500(), }, }, }, [`${base}/get_glyph_summary`]: { post: { ...tags(base), ...security(), ...operation( 'Get glyph summary.', 'Summarizes glyphs that may be traded. Used with add_to_market.' ), ...buildingIdRequestBody, responses: { ...response200('Summarizes glyphs that may be traded. Used with add_to_market.', { type: 'object', required: ['glyphs', 'cargo_space_used_each', 'status'], properties: { glyphs: { type: 'array', items: { type: 'object', properties: { type: { type: 'string' }, quantity: { type: 'integer' } }, }, }, cargo_space_used_each: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/withdraw_from_market`]: { post: { ...tags(base), ...security(), ...operation( 'Withdraw from market.', 'Removes a trade this empire posted and retrieves the offered items.' ), ...requestBodySchema({ type: 'object', required: ['building_id', 'trade_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, trade_id: { type: 'integer', description: 'The unique id of the trade.' }, }, }), responses: { ...response200('Removes a trade this empire posted and retrieves the offered items.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, [`${base}/accept_from_market`]: { post: { ...tags(base), ...security(), ...operation( 'Accept from market.', 'Accepts a trade offer from view_market. Costs the asking price plus 1 essentia. Throws 1016.' ), ...requestBodySchema({ type: 'object', required: ['building_id', 'trade_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, trade_id: { type: 'integer', description: 'The unique id of the trade.' }, }, }), responses: { ...response200( 'Accepts a trade offer from view_market. Costs the asking price plus 1 essentia. Throws 1016.', { type: 'object', required: ['status'], properties: { status: statusSchema() } } ), ...response500(), }, }, }, [`${base}/view_market`]: { post: { ...tags(base), ...security(), ...operation('View market.', 'Lists trades currently available to accept.'), ...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.' }, filter: { type: 'string', enum: ['food', 'ore', 'water', 'waste', 'energy', 'glyph', 'prisoner', 'ship', 'plan'], description: 'Optional. Narrows the list to trades offering one kind of object.', }, }, }), responses: { ...response200('Lists trades currently available to accept.', { type: 'object', required: ['trades', 'trade_count', 'page_number', 'status'], properties: { trades: { type: 'array', items: marketEntrySchema }, trade_count: { type: 'integer' }, page_number: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/view_my_market`]: { post: { ...tags(base), ...security(), ...operation('View my market.', 'Lists trades this empire has posted.'), ...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('Lists trades this empire has posted.', { type: 'object', required: ['trades', 'trade_count', 'page_number', 'status'], properties: { trades: { type: 'array', items: marketEntrySchema }, trade_count: { type: 'integer' }, page_number: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/get_stored_resources`]: { post: { ...tags(base), ...security(), ...operation( 'Get stored resources.', 'Lists resources in storage, to make it easier to decide what to trade.' ), ...buildingIdRequestBody, responses: { ...response200('Lists resources in storage, to make it easier to decide what to trade.', { type: 'object', required: ['resources', 'cargo_space_used_each', 'status'], properties: { resources: { type: 'object', additionalProperties: { type: 'integer' } }, cargo_space_used_each: { type: 'integer' }, status: statusSchema(), }, }), ...response500(), }, }, }, [`${base}/push_items`]: { post: { ...tags(base), ...security(), ...operation( 'Push items.', 'Instantly sends resources/items to another planet this empire owns.' ), ...requestBodySchema({ type: 'object', required: ['building_id', 'target_id', 'items'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, target_id: { type: 'integer', description: 'A planet controlled by this empire.' }, items: { type: 'array', items: tradeableItemSchema, description: 'Resources, glyphs, plans, prisoners, or ships to send.', }, }, }), responses: { ...response200('Instantly sends resources/items to another planet this empire owns.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, [`${base}/trade_one_for_one`]: { post: { ...tags(base), ...security(), ...operation( 'Trade one for one.', 'Trades any resource for another one-for-one, in exchange for 3 essentia.' ), ...requestBodySchema({ type: 'object', required: ['building_id', 'have', 'want', 'quantity'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, have: { type: 'string', description: 'The resource type this empire has. See get_stored_resources.', }, want: { type: 'string', description: 'The resource type this empire wants.' }, quantity: { type: 'integer', description: 'How many to process. Defaults to 1.' }, }, }), responses: { ...response200('Trades any resource for another one-for-one, in exchange for 3 essentia.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, [`${base}/report_abuse`]: { post: { ...tags(base), ...security(), ...operation('Report abuse.', 'Reports a trade suspected of abusing the trade system.'), ...requestBodySchema({ type: 'object', required: ['building_id', 'trade_id'], properties: { building_id: { type: 'integer', description: 'The unique id of the building.' }, trade_id: { type: 'integer', description: 'The unique id of the trade.' }, }, }), responses: { ...response200('Reports a trade suspected of abusing the trade system.', { type: 'object', required: ['status'], properties: { status: statusSchema() }, }), ...response500(), }, }, }, };