]> git.cworth.org Git - lmno-api/blobdiff - api.text
Document the new /profile API
[lmno-api] / api.text
index 48a2eb6b072c499795d0d81a9451ce59ff37ee01..42d4f0ee459dbecc99f313da8557fbf522f8a826 100644 (file)
--- a/api.text
+++ b/api.text
@@ -1,5 +1,11 @@
-Gameplay API endpoints (within a current game)
-==============================================
+Empires Game Protocol
+=====================
+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.
+ The preceding portions of the path must be determined externally.)
+
 /events
 
     This is a server-sent events stream that allows the server to push
@@ -43,6 +49,41 @@ Gameplay API endpoints (within a current game)
                event: player-leave
                data: {"id":3}
 
+       TYPE: game-state
+
+       WHEN: When client first connects and whenever game state changes
+
+       VALUES: Event gives both the old and new state.
+               Each will be one of the following:
+
+               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
+
+       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: {"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
+
+       EXAMPLE:
+
+               event: character-reveal
+                data: {"character":"Albert Einstein"}
+
        TYPE: capture
 
        WHEN: When one player captures another
@@ -56,7 +97,14 @@ Gameplay API endpoints (within a current game)
 
     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" }
 
@@ -66,6 +114,22 @@ Gameplay API endpoints (within a current game)
 
     Behavior: Removes an existing player with the given ID
 
+/reveal
+
+    Method: POST
+
+    When: Only valid when in game state of JOIN
+
+    Behavior: Change state to REVEAL; reveal character names to all clienta
+
+/start
+
+    Method: POST
+
+    When: Only valid when in game state of REVEAL
+
+    Behavior: Change game state to CAPTURE
+
 /reset
 
     Method: POST