Skip to content

Latest commit

 

History

History
961 lines (561 loc) · 24.8 KB

Empire.pod

File metadata and controls

961 lines (561 loc) · 24.8 KB

Founding an empire.

When founding an empire the order of operations is first to fetch_captcha. Then create the empire. Then optionally update_species (default is human). Then finally call the found method to set up the empire on it's new home planet.

Empire Methods

The following methods are available from /empire.

is_name_available ( name )

Returns a 1 if the name is available, or a throws an exception if it is not.

Throws 1000.

name

The name of the empire to search for.

logout ( session_id )

Ends a session. Returns 1.

Throws 1006.

session_id

A session id.

login ( name, password, api_key )

Returns a hash like the following after confirming the password matches the empire.

NOTE: Once established, this session will stick around for up to 2 hours of inactivity. Therefore, you need not login again if you still have a valid session.

{
   "session_id" : "id-goes-here",
   "status" : { ... }
}

Throws 1004 and 1005.

name

The name of the empire.

password

The password to authenticate to the empire.

api_key

Your client's unique API key, identifiying it from all other clients. See ApiKeys for details.

fetch_captcha ( )

Retrieves a captcha that is required in order to call the create method. Display the resulting captcha in your creation form and then call create with the user's response.

{
   "guid" : "id-goes-here",
   "url" : "'https://extras.lacunaexpanse.com.s3.amazonaws.com/captcha/id/id-goes-here.png" 
}

create ( params )

Creates a new empire and then returns an empire_id.

This is not the end of the story though. Now you must either create a update_species for this empire and then found it, or just skip the species part and found the empire.

Throws 1000, 1001, 1002, and 1014.

NOTE: If either captcha_guid or captcha_solution don't match what the server is expecting it will throw a 1014 error, and the data portion of the error message will contain new captcha information. You must use this. A captcha cannot be used more than once.

params

A hash of parameters.

name

The name of the empire to create. Required.

password

The password to log in to the empire. Must be between 6 and 30 characters. Required unless you have a valid facebook_uid and facebook_token. Still recommended even if you are authenticating using Facebook.

password1

Retyping the password again. This must match password to succeed.

captcha_guid

This must match the guid field returned by the fetch_captcha method. Required.

captcha_solution

This is the text typed in by the user as the solution of the captcha. Required.

email

The user's email address. It is not required, but is used for system vital functions like password recovery.

facebook_uid

A Facebook user id passed in through Lacuna's Facebook integration system. Optional, but required with the use of facebook_token.

facebook_token

A Facebook access token passed in through Lacuna's Facebook integration system. Optional, but required with the use of facebook_uid.

invite_code

A 36 character code that was sent to the user by a friend. It is usable only once, and will ensure that their friend gets a home planet that is in relatively close proximity to their home planet.

found ( empire_id, api_key, [ invite_code ] )

Set up an empire on it's new home world. Once this method is called, the species can no longer be modified. Returns:

{
   "session_id" : "id-goes-here",
   "welcome_message_id" : "id-goes-here",
   "status" : { ... }
}

The welcome_message_id is a message id for a message in the inbox, that starts the tutorial. This is provided so the user can be prompted to read that message right away.

empire_id

The empire to found.

api_key

Your client's unique API key, identifiying it from all other clients. See ApiKeys for details.

invite_code

Use of the invite code here is deprecated. Please pass in the invite_code in create instead.

get_invite_friend_url ( session_id )

Returns a URL that can be pasted into a blog, forum, or whatever to invite friends.

{
   "status" : { ... },
   "referral_url" : "http://servername.lacunaexpanse.com/#referral=XXXX"
}

session_id

A session id.

invite_friend ( session_id, email, [ custom_message ] )

Send an invitation code to a friend so that they can start in the same zone as your empire.

{
   "status" : { ... },
   "sent" : [
     "you@there.com",
     ...
   ],
   "not_sent" : [
       {
           "address" : "joe@blow.com",
           "reason" : [ 1009, "Someone has already invited that user." ]
       },
      ...
   ]
}

session_id

A session id.

email

The email address of your friend, or a comma separated string of email addresses.

custom_message

An optional text message that the user can type to invite their friend. This is the default message that will get sent if none is specified:

I'm having a great time with this new game called Lacuna Expanse. Come play with me.

After the message, the user's empire name in the game, the friend code, and URI to the server will be attached.

get_status ( session_id )

Returns information about the current state of the empire.

NOTE: You should probably never call this method directly, as it is a wasted call since the data it returns comes back in the status block of every relevant request. See "Status" in Intro for details.

{
   "server" : { ... },
   "empire" : {
       "id" : "xxxx",
       "colonies" : {
           "id-goes-here" : "Earth",
           "id-goes-here" : "Mars"
       },
       "rpc_count" : 321, # the number of calls made to the server
       "is_isolationist" : 1, # hasn't sent out probes or colony ships
       "name" : "The Syndicate",
       "status_message" : "A spy's work is never done.",
       "home_planet_id" : "id-goes-here",
       "has_new_messages" : 4,
       "latest_message_id" : 1234,
       "essentia" : 0,
       "planets" : {
           "id-goes-here" : "Earth",
           "id-goes-here" : "Mars",
           "id-goes-here" : "Death Star"
       },
       "tech_level"           : 20,  # Highests level university has gotten to.
       "self_destruct_active" : 0,
       "self_destruct_date" : "",
       "stations" : {
           "id-goes-here" : "Death Star"
       },
       "primary_embassy_id" : 234567
   }
}

Throws 1002.

session_id

A session id.

view_profile ( session_id )

Provides a list of the editable properties of the current empire's profile. See also the edit_profile and view_public_profile methods.

{
   "profile" : {
      "description" : "description goes here",
      "status_message" : "status message goes here",
      "medals" : {
          "id-goes-here" : {
              "name" : "Built Level 1 Building",
              "image" : "building1",
              "date" : "01 31 2010 13:09:05 +0600",
              "public" : 1,
              "times_earned" : 4
          },
          ...
      },
      "city" : "Madison",
      "country" : "USA",
      "notes" : "notes go here",
      "skype" : "joeuser47",
      "player_name" : "Joe User",
      "skip_happiness_warnings" : 0,
      "skip_resource_warnings" : 0,
      "skip_pollution_warnings" : 0,
      "skip_medal_messages" : 0,
      "skip_facebook_wall_posts" : 0,
      "skip_found_nothing
      "skip_excavator_resources" : 0,
      "skip_excavator_glyph" : 0,
      "skip_excavator_plan" : 0,
      "skip_spy_recovery" : 0,
      "skip_probe_detected" : 0,
      "skip_attack_messages" : 0,
      "skip_incoming_ships" : 0,
      "email" : "joe@example.com",
      "sitter_password" : "abcdefgh"                   # never give out your real password, use the sitter password
   },
   "status" : { ... }
}

session_id

A session id.

edit_profile ( session_id, profile )

Edits properties of an empire. Returns the view_profile method. See also the view_profile and view_public_profile methods.

Throws 1005, 1009.

session_id

A session id.

profile

A hash reference of properties to be edited. You may set one or all of the profile properties in this hash reference. Only those set will be updated.

description

A description of the empire. Limited to 1024 characters and cannot contain < or >.

email

An email address that can be used for system functions like password recovery. Must either resemble an email address or be empty.

sitter_password

A password that can be safely given to account sitters and alliance members. Must be between 6 and 30 characters.

status_message

A message to indicate what you're doing, how you're feeling, or other status indicator. Limited to 100 characters, cannot be blank, and cannot contain @, &, <, >, or ;.

city

An optional text string of the city in which the player resides. Limited to 100 characters and cannot contain @, &, <, >, or ;

country

An optional text string of the country in which the player resides. Limited to 100 characters and cannot contain @, &, <, >, or ;

notes

A text blob where the user can write down whatever they want to store in their account. Limited to 1024 characters and cannot contain @, &, <, >, or ;

skype

An optional text string of the username this player uses on skype. Limited to 100 characters and cannot contain @, &, <, >, or ;

player_name

An optional text string of the real name or online identity of this player. Limited to 100 characters and cannot contain @, &, <, >, or ;

public_medals

An array reference of medal ids that the user wishes to display in the public profile.

skip_happiness_warnings

Defaults to 0. Set to 1 if the user no longer wants to receive messages about unhappy citizens.

WARNING: These messages are there for your own protection. Turn off at your own risk.

skip_resource_warnings

Defaults to 0. Set to 1 if the user no longer wants to receive messages about a lack of resources to keep their buildings running.

WARNING: These messages are there for your own protection. Turn off at your own risk.

skip_pollution_warnings

Defaults to 0. Set to 1 if the user no longer wants to receive messages about excess waste causing pollution.

WARNING: These messages are there for your own protection. Turn off at your own risk.

skip_medal_messages

Defaults to 0. Set to 1 if the user no longer wants to receive messages about the medals they've earned.

skip_facebook_wall_posts

Defaults to 0. Set to 1 if the user no longer wants messages to be posted to their Facebook wall.

skip_found_nothing

Defaults to 0. Set to 1 if the user no longer wants to receive messages when excavators find nothing.

skip_excavator_resources

Defaults to 0. Set to 1 if the user no longer wants to receive messages when excavators find resources.

skip_excavator_glyph

Defaults to 0. Set to 1 if the user no longer wants to receive messages when excavators find glyphs.

skip_excavator_plan

Defaults to 0. Set to 1 if the user no longer wants to receive messages when excavators find plans.

skip_spy_recovery

Defaults to 0. Set to 1 if the user no longer wants to receive spy recovery messages. ("I'm ready to work. What do you need from me?")

skip_probe_detected

Defaults to 0. Set to 1 if the user no longers wants to receive messages when a probe is detected.

skip_attack_messages

Defaults to 0. Set to 1 if the user no longers wants to receive messages about attacks.

skip_incoming_ships

Controls the display of incoming ships (Own, Allied, Foreign) on your map display. Defaults to 0 (shows ships). Set to 1 if you want to hide incoming ships (can improve response of browser).

view_public_profile (session_id, empire_id)

Provides a list of the data that's publicly known about this empire.

{
   "profile" : {
       "id" : "empire-id-goes-here",
       "name" : "Lacuna Expanse Corp",
       "colony_count" : 1,
       "status_message" : "Looking for Essentia."
       "description" : "We are the original inhabitants of the Lacuna Expanse.",
       "city" : "Madison",
       "country" : "USA",
       "skype" : "joeuser47",
       "player_name" : "Joe User",
       "medals" : {
           "id-goes-here" : {
               "name" : "Built Level 1 Building",
               "image" : "building1",
               "date" : "01 31 2010 13:09:05 +0600",
              "times_earned" : 4
           },
           ...
       },
       "last_login" : "01 31 2010 13:09:05 +0600",
       "date_founded" : "01 31 2010 13:09:05 +0600",
       "species" : "Lacunan",
       "alliance" : {
           "id" : "id-goes-here",
           "name" : "The Confederacy"
       },
       "known_colonies" : [
           {
               "id" : "id-goes-here",
               "x" : "1",
               "y" : "-543",
               "name" : "Earth",
               "image" : "p12-3"
           },
           ...
       ]
   },
   "status" : { ... }
}

Throws 1002.

session_id

A session id.

empire_id

The id of the empire for which you'd like to retrieve the public profile.

send_password_reset_message ( params )

Starts a password recovery process by sending an email with a recovery key.

params

A hash of options to recover a password. Choose one.

empire_id

The unique id of the empire to recover.

empire_name

The full name of the empire.

email

The email address associated with an empire.

reset_password ( reset_key, password1, password2, api_key )

Change the empire password that has been forgotten.

{
  "session_id" : "id-goes-here",
  "status" : { ... }
}

reset_key

A key that was emailed to the user via the send_password_reset_message method.

password1

The password to log in to the empire. Required. Must be between 6 and 30 characters.

password2

Retyping the password again. This must match password1 to succeed.

api_key

Your client's unique API key, identifiying it from all other clients. See ApiKeys for details.

change_password ( session_id, password1, password2 )

Change the empire password.

session_id

A session id.

password1

The password to log in to the empire. Required. Must be between 6 and 30 characters.

password2

Retyping the password again. This must match password1 to succeed.

find ( session_id, name )

Find an empire by name. Returns a hash reference containing empire ids and empire names. So if you searched for "Lacuna" you might get back a result set that looks like this:

{
   "empires" : [
       {
           "id" : "id-goes-here",
           "name" : "Lacuna Expanse Corp"
       },
       {    
           "id" : "id-goes-here2",
           "name" : "Lacuna Pirates"
       }
   ],
   "status" : { ... }
}

session_id

A session id.

name

The name your searching for. It's case insensitive, and partial names work fine. Must be at least 3 characters.

set_status_message ( session_id, message )

Sets the empire status message. Similar to what you might put on your Facebook wall, or in a tweet, but about your empire.

session_id

A session id.

message

A message to indicate what you're doing, how you're feeling, or other status indicator. Limited to 100 characters, cannot be blank, and cannot contain @, &, <, >, or ;.

view_boosts ( session_id )

Shows the dates at which boosts have expired or will expire. Boosts are subsidies applied to various resources using essentia.

{
   "status" : { ... },
   "boosts" : {
       "food" : "01 31 2010 13:09:05 +0600",
       "ore" : "01 31 2010 13:09:05 +0600",
       "energy" : "01 31 2010 13:09:05 +0600",
       "water" : "01 31 2010 13:09:05 +0600",
       "happiness" : "01 31 2010 13:09:05 +0600",
       "storage" : "01 31 2010 13:09:05 +0600",
       "building" : ""01 31 2010 13:09:05 +0600"
       "spy_training_boost" : ""01 31 2010 13:09:05 +0600"
   }
}

session_id

A session id.

boost_storage ( session_id )

Spends 5 essentia, and boosts storage (all 5 types) on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.

{
   "status" : { ... },
   "storage_boost" : "01 31 2010 13:09:05 +0600"
}

Throws 1011.

session_id

A session id.

boost_food ( session_id )

Spends 5 essentia, and boosts food production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.

{
   "status" : { ... },
   "food_boost" : "01 31 2010 13:09:05 +0600"
}

Throws 1011.

session_id

A session id.

boost_water ( session_id )

Spends 5 essentia, and boosts water production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.

{
   "status" : { ... },
   "water_boost" : "01 31 2010 13:09:05 +0600"
}

Throws 1011.

session_id

A session id.

boost_energy ( session_id )

Spends 5 essentia, and boosts energy production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.

{
   "status" : { ... },
   "energy_boost" : "01 31 2010 13:09:05 +0600"
}

Throws 1011.

session_id

A session id.

boost_ore ( session_id )

Spends 5 essentia, and boosts ore production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.

{
   "status" : { ... },
   "ore_boost" : "01 31 2010 13:09:05 +0600"
}

Throws 1011.

session_id

A session id.

boost_happiness ( session_id )

Spends 5 essentia, and boosts happiness production on all planets for 7 days. If a boost is already underway, calling again will add 7 more days.

{
   "status" : { ... },
   "happiness_boost" : "01 31 2010 13:09:05 +0600"
}

Throws 1011.

session_id

A session id.

boost_building ( session_id )

Spends 5 essentia, and boosts build queues on all planets for 7 days. If a boost is already underway, calling again will add 7 more days. It will not boost builds currently under way, only new builds added to a build queue.

{
   "status" : { ... },
   "building_boost" : "01 31 2010 13:09:05 +0600"
}

Throws 1011.

session_id

A session id.

spy_training_boost ( session_id )

Spends 5 essentia, and boosts spy training speed on all planets 50% for 7 days. If a boost is already underway, calling again will add 7 more days. Unlike other boosts, this one will boost spies currently in specialist training.

{
   "status" : { ... },
   "spy_training_boost" : "01 31 2010 13:09:05 +0600"
}

Throws 1011.

session_id

A session id.

enable_self_destruct ( session_id )

Enables a destruction countdown of 24 hours. Sometime after the timer runs out, the empire will vaporize.

{
   "status" : { ... }
}

session_id

A session id.

disable_self_destruct ( session_id )

Disables the self distruction countdown.

{
   "status" : { ... }
}

session_id

A session id.

redeem_essentia_code ( session_id, code )

Redeems an essentia code and applies the essentia to the empire's balance.

{
   "status" : { ... }
}

session_id

A session id.

code

A 36 character string that was sent to the user via email.

update_species ( empire_id, params )

Updates the empire's species and returns 1. Can only be called after create has been called and before found has been called. Before or after that will throw an exception. If you have already founded your empire then use redefine_species.

See also: get_species_templates

Throws 1000, 1002, 1005, 1007, 1008, 1009, and 1010. The data parameter will contain the field name that needs to be adjusted, if it can be attributed to a single field.

empire_id

The id of the empire you wish to update a species for.

params

A hash reference of parameters. With the exception of name and description, the parameters are all integers. When added together they must equal 45.

name

The name of the species. Limited to 30 characters, cannot be blank, and cannot contain @, &, <, >, or ;. Required.

description

The species description. Limited to 1024 characters and cannot contain < or >.

min_orbit

An integer between between 1 and 7, inclusive, where 1 is closest to the star. Each value between min_orbit and max_orbit, inclusive, count as a point toward the max of 45. min_orbit must be less than or equal to max_orbit.

max_orbit

An integer between between 1 and 7, inclusive, where 1 is closest to the star. Each value between min_orbit and max_orbit, inclusive, count as a point toward the max of 45. max_orbit must be greater than or equal to min_orbit.

manufacturing_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages manufactured goods, such as ships.

deception_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in spying.

research_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in upgrading buildings.

management_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in the speed of building.

farming_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in food production.

mining_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in mineral production.

science_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in energy, propultion, and other technologies.

environmental_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in waste and water management.

political_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in managing population happiness.

trade_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in freight handling.

growth_affinity

An integer between 1 and 7 inclusive, where 7 is best. Determines species advantages in colonization.

redefine_species_limits ( session_id )

Defines the extra limits placed upon a user that want's to redefine their species.

{
   "status" : { ... },
   "essentia_cost" : 100,   # cost to redefine the species
   "max_orbit" : 2,         # maximum settable orbit
   "min_orbit" : 5,         # minimum settable orbit
   "min_growth" : 4,        # minimum for growth affinity
   "can" : 0,               # whether or not they can redefine their species
   "reason" : "You have already redefined your species in the past 30 days."
}

session_id

A session id.

redefine_species ( session_id, params )

Allows a user to spend essentia and redefine their species affinities, name, and description. This can only be used after the empire has been founded. If you want to redefine the species during empire creation then see update_species.

See also redefine_species_limits.

{
   "status" : { ... }
}

WARNING: Once this is done it cannot be redone for 1 month, so make sure the user is aware of this and prompt them appropriately before submitting the request.

session_id

A ssession id.

params

See the params list in the update_species method.

view_species_stats ( session_id )

Returns a list of the stats associated with an empire's species as it was originally created. An empire can only view it's own species stats through this method.

{
   "species" : {
      "name" : "Human",
      "description" : "The descendants of Earth.",
      "min_orbit" : 3,
      "max_orbit" : 3,
      "manufacturing_affinity" : 4,
      "deception_affinity" : 4,
      "research_affinity" : 4,
      "management_affinity" : 4,
      "farming_affinity" : 4,
      "mining_affinity" : 4,
      "science_affinity" : 4,
      "environmental_affinity" : 4,
      "political_affinity" : 4,
      "trade_affinity" : 4,
      "growth_affinity" : 4
   },
   "status" : { ... }
}

get_species_templates ( )

Returns an array ref of species templates that can be used to help the user populate the form for update_species.

[
   {
      "name" : "Average", 
       "description" : "A race of average intellect, and weak constitution.',
       "min_orbit" : 3,
       "max_orbit" : 3,
       "manufacturing_affinity" : 4,
       "deception_affinity" : 4,
       "research_affinity" : 4,
       "management_affinity" : 4,
       "farming_affinity" : 4,
       "mining_affinity" : 4,
       "science_affinity" : 4,
       "environmental_affinity" : 4,
       "political_affinity" : 4,
       "trade_affinity" : 4,
       "growth_affinity" : 4
   },
   ...
]