]> git.cworth.org Git - lmno-api/blobdiff - api.text
Document the new /profile API
[lmno-api] / api.text
index 250ed107c86aad50698332b5185a5402c85debf2..42d4f0ee459dbecc99f313da8557fbf522f8a826 100644 (file)
--- a/api.text
+++ b/api.text
@@ -1,6 +1,6 @@
 Empires Game Protocol
 =====================
-Version: 0.4
+Version: 0.6
 
 For a specific game the following API endpoints are defined.
 (Note: Only the trailing portion of the API URI is provided here.
@@ -53,20 +53,31 @@ For a specific game the following API endpoints are defined.
 
        WHEN: When client first connects and whenever game state changes
 
-       VALUES: Game state will be one of the following:
+       VALUES: Event gives both the old and new state.
+               Each will be one of the following:
 
-               JOIN: Players are choosing characters and joining the game
-                REVEAL: Character names are being revealed to players
-                CAPTURE: Players are guessing characters in capture attempts
+               none: Pseudo-state used as old_state when game is started
+               join: Players are choosing characters and joining the game
+                reveal: Character names are being revealed to players
+                capture: Players are guessing characters in capture attempts
 
-       EXAMPLE:
+       NOTE: When a client first connects, it may see multiple
+             game-state transitions, to transition step-by-step from
+             the initial state to the state of the current game. See
+             the example below which would be presented to a client
+             joining a game that is already in the "reveal state.
+
+       EXAMPLES:
 
                event: game-state
-                data: {"state":"REVEAL"}
+                data: {"old_state":"none","new_state":"join"}
+
+               event: game-state
+                data: {"old_state":"join","new_state":"reveal"}
 
        TYPE: character-reveal
 
-       WHEN: Periodically during the REVEAL state of the game
+       WHEN: Periodically during the "reveal" state of the game
 
        EXAMPLE:
 
@@ -86,7 +97,14 @@ For a specific game the following API endpoints are defined.
 
     Method: POST
 
-    Behavior: Adds a new player with "name" and "character" and assigns an id. Also will add a new empire with empty "captured" array
+    Behavior: Adds a new player with "name" and "character" and
+    assigns an id. Also will add a new empire with empty "captured"
+    array.
+
+    Note: If the client supports cookies and has previously set a
+    nickname in the current session via the upper-level /profile API,
+    then the name can be omitted from the data here and the profile
+    nickname will be used instead.
 
     Example data: { "name": "Carl", "character: "Elvis" }