You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DOCS.md
+11-5Lines changed: 11 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
### General Notes
4
4
⚠️ FastAPI automatically generates Swagger-style documentation at /docs for all the HTTP endpoints (no WebSockets).
5
5
6
-
⚠️ The default API endpoint starts with `/api` (after your host address)
6
+
⚠️ The default API endpoint starts with `/api` (after your host address)
7
7
8
8
⚠️ The URL suffix matters! When connecting to HTTP endpoints you'll use `http://` but whe connecting to WS endpoints you'll use `ws://`. The secure version of these protocols are `https://` and `wss://`, respectively.
9
9
@@ -38,7 +38,7 @@ ALTERNATIVELY: Send a POST request to `/api/users/guest` to get `access_token` a
38
38
1. To start queueing for a match, join the WebSocket endpoint `/game/queue` (unranked) or `/game/ranked-queue` (ranked).
39
39
- These two are pretty much the same, except ranked games are matched based on rating proximity and give rating changes.
40
40
- The problems distribution in unranked matches are based on appearance chances, but in ranked the distribution of problemsare predetermined (check .env settings)
41
-
2. Once a match is found, a WebSocket JSON object of `type: "match_found"` will be sent to you. Inside `data` includes information like your `"match_id"` and opponent details.
41
+
2. Once a match is found, a WebSocket JSON object of `type: "match_found"` will be sent to you. Inside `data` includes information like your `"match_id"` and opponent details.
42
42
3. Use the mentioned `"match_id"` to connect to the WebSocket of the game e.g. `/game/play/{match_id}`
43
43
4. While inside the game websocket, here are the messages you'll receive:
44
44
-`type: "game_state"`: sent on join/query; contains information about the current state of the game (you and your opponent)
@@ -52,7 +52,7 @@ ALTERNATIVELY: Send a POST request to `/api/users/guest` to get `access_token` a
52
52
-`code: string`: your code string (includes boilerplate)
53
53
-`lang: 'python' | 'java' | 'cpp'`: your code's language
54
54
-`type: "forfeit"`: used to forfeit the match
55
-
-`type: "query"`: used to fetch current match data.
55
+
-`type: "query"`: used to fetch current match data.
56
56
-`type: "ability"`: used to signal a buy/use of abilities. Inside your `"data"` property:
57
57
-`action: string`: either `buy` or `use`
58
58
-`ability_id: string`: the ID string of the ability
@@ -87,6 +87,12 @@ ALTERNATIVELY: Send a POST request to `/api/users/guest` to get `access_token` a
87
87
-`type: "chat"`: used to send a message to your opponent in the room. Inside your `"data"` property:
88
88
-`message: string`: the message you want to send
89
89
90
+
#### 9. Practice Mode
91
+
1. Connect to practice mode WebSocket at `/practice`.
92
+
2. You will receive the same JSON objects as in the [Game Mode](#4-matchmaking-and-game-flow)
93
+
3. Additional JSON objects you can send:
94
+
-`type: "change_bot_difficulty"`: change the difficulty of the bot ("easy", "medium", "hard") in `"difficulty"` field inside `"data"`.
95
+
90
96
⚠️ Both players will still remain in the room while in-match.
91
-
⚠️ Disconnection from the room WebSocket counts as leaving the room.
92
-
> Hence it is advised the frontend keeps the room WebSocket alive during game as well and have the players return to the room screen after finishing the match e.g. `"match_end"` event
97
+
⚠️ Disconnection from the room WebSocket counts as leaving the room.
98
+
> Hence it is advised the frontend keeps the room WebSocket alive during game as well and have the players return to the room screen after finishing the match e.g. `"match_end"` event
0 commit comments