-
Notifications
You must be signed in to change notification settings - Fork 0
API Design
Sumeet Grewal edited this page Dec 16, 2020
·
14 revisions
| Resource | GET | POST | PUT | DELETE |
|---|---|---|---|---|
/game/connect |
subscribe to game SSE | restart game | exit game | |
/game/setup |
add player to game {username, password} | update player {status, board} | ||
/game/play |
handle player card selection | |||
/game/assets |
get boards and cards in play |
/game/connect
-
joinedlistener - when client subscribes to SSE- receives confirmation of connection
-
keepalivelistener- maintains SSE connection by pinging every 50 second
/game/setup
-
playerUpdatelistener- receives player data when 1) a new players joins the game lobby or 2) a player "is ready"
-
setupUpdatelistener- receives gamestatus and setupData:
- playerOrder
- turnToChoose
- boards
- assignedBoards
- receives gamestatus and setupData:
-
gameUpdatelistener- receives players and gameStatus ("join"/"lobby"/"boardSelection"/"game")
/game/play
-
turnUpdatelistener- receives
- metadata - age, turn, etc.
- currentHand - array of card IDs in hand
- handInfo - canBuild flag, coinCost, and PurchaseOptions for each card in hand
- stageInfo - Whether a player can build the next stage
- isWaiting = false (reset isWaiting flag)
- receives
-
playerDataUpdatelistener- receives data for given player
-
allPlayerDataUpdatelistener- receives data for all other players besides given player
-
gameFeedlistener- received game feed data {player, type, message, card?}[]
- turn data at end of each turn (card selected/discarded/staged)
- military data at end of each age
- payment data if you pay or receive coins
- received game feed data {player, type, message, card?}[]