]> git.cworth.org Git - empires-api/blobdiff - tictactoe.txt
Document player-info, player-enter, and player-update events
[empires-api] / tictactoe.txt
index 62046a6e23822d5d72f907c95adfb9f2c6c39826..95a706c5d349fa152c3e0839aa07ebc1e8229b6b 100644 (file)
@@ -26,6 +26,76 @@ For a specific game the following API endpoints are defined.
 
     The following event types will be returned by the server:
 
+       TYPE: game-info
+
+       WHEN: When a client first connects
+
+       WHAT: Static information about the game (will not change)
+
+        EXAMPLE:
+
+               event: game-info
+                data: {"id":"WXYZ","url":"https://lmno.games/WXYZ"}
+
+       TYPE: player-info
+
+       WHEN: When a client first connects
+
+       WHAT: Information about the current player (ID, name, and team)
+
+       NOTE: The player-info event is unique among player-* events in
+             that it only describes the player associated with the
+             current client connection. Meanwhile, player-enter and
+             player-update events can describe the current player or
+             any other. The player-info event is significant because
+             the client may not know its own name other than
+             receiving it here, (such as if the client offers up a
+             pre-existing cookie and the server uses that to return a
+             player name from a server-side session object).
+
+       EXAMPLE:
+
+               event: player-info
+                data: {"id":0,"name":"Carl","team":"X"}
+
+       TYPE: player-enter
+
+       WHEN: Whenever a new player enters the game. Also: these
+              events will be streamed out for all existing players
+              when a client first connects
+
+       WHAT: Information about the new player (ID, name, and team)
+
+       EXAMPLE:
+
+               event: player-enter
+                data: {"id":1,"name":"Stacy","team":"O"}
+
+       TYPE: player-update
+
+       WHEN: Whenever a player updates their information
+
+       WHAT: All information about the updating player. The ID value
+              cannot be changed, so it can be used by the client to
+              know which player object to update. Player may change
+              either their name, their team, or both.
+
+       EXAMPLE:
+
+               event: player-update
+                data: {"id":0,"name":"Carl Worth","team":"O"}
+
+       TYPE: game-state
+
+       WHEN: When a client first connects
+
+       WHAT: Snapshot of the current dynamic game state
+
+       EXAMPLE:
+
+               event: game-state
+               data: {"moves":[0,8],"board":["X","","","","","","","","O"],"next_player":"X"}
+
        TYPE: move
 
        WHEN: When a client (maybe yourself) issues a legal move
@@ -41,4 +111,4 @@ For a specific game the following API endpoints are defined.
 
     Behavior: Adds a new move to the game
 
-    Example data: { "square": 4 }
+    Example data: { "move": 1 }