import Lacuna from '../lacuna'; import Endpoint from '../core/endpoint'; import * as E from '../types/empire'; class Empire extends Endpoint { lacuna: Lacuna; module: string; constructor(lacuna: Lacuna, module: string) { super(); this.lacuna = lacuna; this.module = module; } isNameAvailable(params: E.IsNameAvailableParams) { return this.callWithoutSession('is_name_available', params); } fetchCaptcha(params: E.FetchCaptchaParams = {}) { return this.callWithSession('fetch_captcha', params); } /** * Creates an empire, which then has to be founded (optionally updating its * species first) before it can be played. A captcha can only be used once, * so a 1014 carries a fresh one in its error data for the next attempt. */ create(params: E.CreateParams) { return this.callWithoutSession('create', params); } /** Sets an empire up on its home world. Its species can't be changed afterwards. */ found(params: E.FoundParams) { return this.callWithoutSession('found', params); } getInviteFriendUrl(params: E.GetInviteFriendUrlParams = {}) { return this.callWithSession('get_invite_friend_url', params); } inviteFriend(params: E.InviteFriendParams) { return this.callWithSession('invite_friend', params); } viewBoosts(params: E.ViewBoostsParams = {}) { return this.callWithSession('view_boosts', params); } getStatus(params: E.GetStatusParams = {}) { return this.callWithSession('get_status', params); } login(params: E.LoginParams) { return this.callWithoutSession('login', params); } logout() { return this.callWithSession('logout', {}); } viewProfile(params: E.ViewProfileParams = {}) { return this.callWithSession('view_profile', params); } /** Only the properties present in `profile` are updated. */ editProfile(params: E.EditProfileParams) { return this.callWithSession('edit_profile', params); } viewPublicProfile(params: E.ViewPublicProfileParams) { return this.callWithSession('view_public_profile', params); } /** Emails a reset key to the empire, for `resetPassword` to consume. */ sendPasswordResetMessage(params: E.SendPasswordResetMessageParams = {}) { return this.callWithoutSession( 'send_password_reset_message', params ); } resetPassword(params: E.ResetPasswordParams) { return this.callWithoutSession('reset_password', params); } changePassword(params: E.ChangePasswordParams) { return this.callWithSession('change_password', params); } find(params: E.FindParams) { return this.callWithSession('find', params); } setStatusMessage(params: E.SetStatusMessageParams) { return this.callWithSession('set_status_message', params); } boostFood(params: E.BoostParams = {}) { return this.callWithSession('boost_food', params); } boostWater(params: E.BoostParams = {}) { return this.callWithSession('boost_water', params); } boostEnergy(params: E.BoostParams = {}) { return this.callWithSession('boost_energy', params); } boostOre(params: E.BoostParams = {}) { return this.callWithSession('boost_ore', params); } boostHappiness(params: E.BoostParams = {}) { return this.callWithSession('boost_happiness', params); } boostBuilding(params: E.BoostParams = {}) { return this.callWithSession('boost_building', params); } boostSpyTraining(params: E.BoostParams = {}) { return this.callWithSession('boost_spy_training', params); } boostStorage(params: E.BoostParams = {}) { return this.callWithSession('boost_storage', params); } /** Starts a 24 hour countdown, after which the empire is vaporized. */ enableSelfDestruct(params: E.EnableSelfDestructParams = {}) { return this.callWithSession('enable_self_destruct', params); } disableSelfDestruct(params: E.DisableSelfDestructParams = {}) { return this.callWithSession('disable_self_destruct', params); } redeemEssentiaCode(params: E.RedeemEssentiaCodeParams) { return this.callWithSession('redeem_essentia_code', params); } /** * Sets the species of an empire that has been created but not yet founded. * Use `redefineSpecies` once it has been founded. Sessionless despite the * spec marking it otherwise: the empire is identified by `empire_id`, and * there's no session to be had until the empire is founded anyway. */ updateSpecies(params: E.UpdateSpeciesParams) { return this.callWithoutSession('update_species', params); } // The spec has this one unauthenticated, but the server reads the empire off // the session to work out its limits, so it's a session call in practice. redefineSpeciesLimits(params: E.RedefineSpeciesLimitsParams = {}) { return this.callWithSession('redefine_species_limits', params); } /** * Spends essentia to redefine a founded empire's species. Can't be redone * for a month afterwards, so prompt the user before calling it. */ redefineSpecies(params: E.RedefineSpeciesParams) { return this.callWithSession('redefine_species', params); } viewSpeciesStats(params: E.ViewSpeciesStatsParams = {}) { return this.callWithSession('view_species_stats', params); } /** Ready-made species to populate an `updateSpecies` form with. */ getSpeciesTemplates(params: E.GetSpeciesTemplatesParams = {}) { return this.callWithoutSession('get_species_templates', params); } viewAuthorizedSitters(params: E.ViewAuthorizedSittersParams = {}) { return this.callWithSession('view_authorized_sitters', params); } authorizeSitters(params: E.AuthorizeSittersParams) { return this.callWithSession('authorize_sitters', params); } deauthorizeSitters(params: E.DeauthorizeSittersParams) { return this.callWithSession('deauthorize_sitters', params); } } export default Empire;