1 Gameplay API endpoints (within a current game)
2 ==============================================
5 This is a server-sent events stream that allows the server to push
6 game-related events to clients. When a client connects to this API
7 endpoint the server will return a header that includes:
9 Content-type: text/event-stream
10 Connection: keep-alive
11 Cache-Control: no-cache
13 and will keep the connection open to return events.
15 The following event types will be returned by the server:
19 WHEN: When a client first connects
21 PURPOSE: Describes all players in the game already
26 data: [{"id":1,"name":"Carl"},{"id":2,"name":"Kevin"}]
30 WHEN: When a player joins the game
35 data: {"id":3,"name":"Richard"}
39 WHEN: When a player leaves the game
48 WHEN: When one player captures another
53 data: {"captor": 2, "captee": 1}
59 Behavior: Adds a new player with "name" and "character" and assigns an id. Also will add a new empire with empty "captured" array
61 Example data: { "name": "Carl", "character: "Elvis" }
67 Behavior: Removes an existing player with the given ID
73 Behavior: Removes all players (bulk deregister)
79 Behavior: Eliminates all current empire ownership so the existing
80 players can start a new game
86 Behavior: Indicate that empire ID1 has now captured ID2
92 Behavior: Indicate that empire ID is no longer captured (undoing a
99 Behavior: Returns a lists of all character names (in alphabetical order)
101 Example data: [ "Einstein", "Elvis", "Fred Flintstone" ]
107 Behavior: Shows which empires have been captured by other empires
109 Example data [ { "id": 1, "captures": [] },
110 { "id": 2, "captures": [1] },
111 { "id": 3, "captures": [4, 5, 6] },
112 { "id": 4, "captures": [2] },
113 { "id": 5, "captures": [] },
114 { "id": 6, "captures": [] } ]
120 Behavior: Gets a list of all the player objects (without their
123 Example data: [ { id: 1, name: "Carl" }, { id: 2, name: "Kevin" } ]
127 There's a sample server available at: https://families.cworth.org/api/
129 We plan to move this to https://empires.cworth.org at some point.