import { ServerDate, IntBool } from '.'; import { EmpireBlock, ServerBlock, StatusBlock } from './status'; /** * A species definition. Every field except name and description is an integer * between 1 and 7, and those integers must add up to exactly 45. */ export interface Species { name: string; description: string; /** The closest orbit this species can inhabit, where 1 is nearest the star. */ min_orbit: number; /** The furthest orbit this species can inhabit, where 1 is nearest the star. */ max_orbit: number; manufacturing_affinity: number; deception_affinity: number; research_affinity: number; management_affinity: number; farming_affinity: number; mining_affinity: number; science_affinity: number; environmental_affinity: number; political_affinity: number; trade_affinity: number; growth_affinity: number; } /** The notification opt-outs shared by the readable and writable profile shapes. */ interface ProfileSkipFlags { skip_happiness_warnings: IntBool; skip_resource_warnings: IntBool; skip_pollution_warnings: IntBool; skip_medal_messages: IntBool; skip_found_nothing: IntBool; skip_excavator_resources: IntBool; skip_excavator_glyph: IntBool; skip_excavator_plan: IntBool; skip_spy_recovery: IntBool; skip_probe_detected: IntBool; skip_attack_messages: IntBool; skip_incoming_ships: IntBool; // // Sent by the server but undocumented in the spec. See README "Spec Discrepancies". // skip_excavator_destroyed?: IntBool; skip_excavator_artifact?: IntBool; skip_excavator_replace_msg?: IntBool; dont_replace_excavator?: IntBool; } /** Keyed by medal id. */ export interface ProfileMedals { [medalId: string]: { name: string; image: string; date: ServerDate; public: IntBool; times_earned: number; }; } /** The profile as `view_profile`/`edit_profile` return it, to its own empire. */ export interface Profile extends ProfileSkipFlags { description: string; status_message: string; medals: ProfileMedals; city: string; country: string; notes: string; skype: string; player_name: string; email: string; sitter_password: string; } /** * The properties `edit_profile` accepts. Everything is optional - only the * properties present in the request are updated. Note `public_medals`, which * is writable here but read back as the `public` flag on each entry of the * `medals` map. */ export interface EditableProfile extends Partial { /** Limited to 1024 characters and cannot contain < or >. */ description?: string; /** Limited to 100 characters, cannot be blank, and cannot contain @, &, <, >, or ;. */ status_message?: string; /** The ids of the medals the user wishes to display in the public profile. */ public_medals?: number[]; city?: string; country?: string; notes?: string; skype?: string; player_name?: string; email?: string; /** Safe to give to account sitters. Must be between 6 and 30 characters. */ sitter_password?: string; } /** Ore concentrations, as reported for a body in a public profile. */ export interface OreConcentrations { anthracite: number; bauxite: number; beryl: number; chalcopyrite: number; chromite: number; fluorite: number; galena: number; goethite: number; gold: number; gypsum: number; halite: number; kerogen: number; magnetite: number; methane: number; monazite: number; rutile: number; sulfur: number; trona: number; uraninite: number; zircon: number; } /** The profile as `view_public_profile` returns it, to anyone. */ export interface PublicProfile { id: number; name: string; species: string; description: string; city: string; country: string; skype: string; player_name: string; status_message: string; date_founded: ServerDate; last_login: ServerDate; colony_count: number; /** Keyed by medal id. Every medal here is public, so there's no `public` flag. */ medals: { [medalId: string]: { name: string; image: string; date: ServerDate; times_earned: number; }; }; known_colonies: Array<{ id: number; name: string; type: string; image: string; notes: string; star_id: number; star_name: string; orbit: number; x: number; y: number; zone: string; size: number; water: number; /** Only sent, as 1, for the empire's home world. */ homeworld?: 1; ore?: OreConcentrations; empire?: { id: number; name: string; alignment: 'ally' | 'self' | 'hostile'; is_isolationist: IntBool; }; }>; /** Sent when the empire is in an alliance. Undocumented in the spec. */ alliance?: { id: number; name: string }; } export interface IsNameAvailableParams { name: string; } /** 1 when the name is free; the server throws 1000 rather than returning 0. */ export type IsNameAvailableResponse = IntBool; export interface CreateParams { name: string; /** Must match the `guid` returned by `fetch_captcha`. */ captcha_guid: string; captcha_solution: string; /** * Must be between 6 and 30 characters. */ password?: string; /** Must match `password`. Required whenever `password` is supplied. */ password1?: string; /** Not required, but used for password recovery. */ email?: string; /** A 36 character code sent to the user by a friend. Usable only once. */ invite_code?: string; } /** The new empire's id. It still has to be founded before it can be played. */ export type CreateResponse = number; export interface FoundParams { empire_id: number; api_key: string; /** @deprecated Pass `invite_code` to `create` instead. */ invite_code?: string; } export interface FoundResponse { session_id: string; /** An inbox message that starts the tutorial. */ welcome_message_id: number; status: StatusBlock; } export interface GetInviteFriendUrlParams {} export interface GetInviteFriendUrlResponse { referral_url: string; status: StatusBlock; } export interface InviteFriendParams { /** One email address, or a comma separated string of them. */ email: string; /** Appended with the empire name, friend code, and server URI. */ custom_message?: string; } export interface InviteFriendResponse { sent: string[]; /** Each entry pairs the address with the `[code, message]` it failed with. */ not_sent: Array<{ address: string; reason: [number, string] }>; status: StatusBlock; } export interface ViewBoostsParams {} export interface ViewBoostsResult { boosts: { food: ServerDate; ore: ServerDate; energy: ServerDate; water: ServerDate; happiness: ServerDate; storage: ServerDate; building: ServerDate; spy_training: ServerDate; }; } export interface BoostParams { /** The number of 7 day boost periods to buy at once, at 5 essentia each. Defaults to 1. */ weeks?: number; } export interface GetStatusParams {} export interface GetStatusResponse { empire: EmpireBlock; server: ServerBlock; } export interface FetchCaptchaParams {} export interface FetchCaptchaResponse { guid: string; url: string; } export interface LoginParams { empire_name: string; password: string; api_key: string; } export interface LoginResponse { session_id: string; status?: StatusBlock; } export type LogoutResponse = IntBool; export interface ViewProfileParams {} export interface ViewProfileResponse { profile: Profile; status: StatusBlock; } export interface EditProfileParams { profile: EditableProfile; } /** Identical to `view_profile`'s. */ export type EditProfileResponse = ViewProfileResponse; export interface ViewPublicProfileParams { empire_id: number; } export interface ViewPublicProfileResponse { profile: PublicProfile; status: StatusBlock; } /** Identify the empire by exactly one of `empire_id`, `empire_name`, or `email`. */ export interface SendPasswordResetMessageParams { empire_id?: number; empire_name?: string; email?: string; } export interface SendPasswordResetMessageResponse { sent: IntBool; } export interface ResetPasswordParams { /** Emailed to the user by `send_password_reset_message`. */ reset_key: number; /** Must be between 6 and 30 characters. */ password1: string; /** Must match `password1`. */ password2: string; api_key: string; } /** The same shape `login` returns. */ export interface ResetPasswordResponse { session_id: string; status: StatusBlock; } export interface ChangePasswordParams { /** Must be between 6 and 30 characters. */ password1: string; /** Must match `password1`. */ password2: string; } export interface ChangePasswordResponse { status: StatusBlock; } export interface FindParams { /** Case insensitive, partial names are fine, and must be at least 3 characters. */ name: string; } export interface FindResponse { empires: Array<{ id: number; name: string }>; status: StatusBlock; } export interface SetStatusMessageParams { /** Limited to 100 characters, cannot be blank, and cannot contain @, &, <, >, or ;. */ message: string; } /** * The status block itself, not a `{status}` wrapper - the same shape * `get_status` returns. See README "Spec Discrepancies". */ export interface SetStatusMessageResponse { empire: EmpireBlock; server: ServerBlock; } export interface EnableSelfDestructParams {} export interface EnableSelfDestructResponse { status: StatusBlock; } export interface DisableSelfDestructParams {} export interface DisableSelfDestructResponse { status: StatusBlock; } export interface RedeemEssentiaCodeParams { /** A 36 character string that was sent to the user via email. */ code: string; } export interface RedeemEssentiaCodeResponse { /** The essentia the code was worth. */ amount: number; status: StatusBlock; } export interface UpdateSpeciesParams { empire_id: number; params: Species; } export type UpdateSpeciesResponse = IntBool; export interface RedefineSpeciesLimitsParams {} export interface RedefineSpeciesLimitsResponse { essentia_cost: number; max_orbit: number; min_orbit: number; min_growth: number; can: IntBool; /** null, rather than absent, when a redefinition is allowed. */ reason: string | null; status: StatusBlock; } export interface RedefineSpeciesParams { params: Species; } export interface RedefineSpeciesResponse { status: StatusBlock; } export interface ViewSpeciesStatsParams {} export interface ViewSpeciesStatsResponse { species: Species; status: StatusBlock; } export interface GetSpeciesTemplatesParams {} export type GetSpeciesTemplatesResponse = Species[]; export interface ViewAuthorizedSittersParams {} export interface ViewAuthorizedSittersResponse { sitters: Array<{ id: number; name: string; expiry: ServerDate }>; status: StatusBlock; } /** One or more of these. */ export interface AuthorizeSittersParams { /** Selects every ally. */ allied?: IntBool; /** The name of another alliance, all of whom are selected. */ alliance?: string; /** The id of another alliance, all of whom are selected. */ alliance_id?: number; /** The ids and/or names of specific empires being authorized. */ empires?: Array; /** Extends the authorization period of every currently-authorized empire. */ revalidate_all?: IntBool; } /** * `view_authorized_sitters`' response plus whatever couldn't be resolved to an * empire, echoed back as it was passed. See README "Spec Discrepancies". */ export interface AuthorizeSittersResponse extends ViewAuthorizedSittersResponse { rejected_ids: Array; } /** One of `empires` or `deauthorize_all` is required. */ export interface DeauthorizeSittersParams { /** The ids (not names) of specific empires being removed. */ empires?: number[]; /** * Removes every current sitter. Ignored if `empires` is given. The server * treats any value (even 0) as true, so omit it rather than sending 0. */ deauthorize_all?: 1; } /** `view_authorized_sitters`' response, minus whoever was just removed. */ export type DeauthorizeSittersResponse = ViewAuthorizedSittersResponse;