Skip to content

Commit b06c259

Browse files
S1M0N38claude
andcommitted
docs(dev): improve code documentation and comments
- Add detailed documentation for EVENT_QUEUE_THRESHOLD constant explaining the heuristic for game state stability - Document DebugPlus integration with reference to GitHub repo and optional dependency behavior - Enhance assert_error_response docstring with parameter descriptions and usage details Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 514c29c commit b06c259

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

src/lua/api.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ local json = require("json")
44
-- Constants
55
local UDP_BUFFER_SIZE = 65536
66
local SOCKET_TIMEOUT = 0
7+
-- The threshold for determining when game state transitions are complete.
8+
-- This value represents the maximum number of events allowed in the game's event queue
9+
-- to consider the game idle and waiting for user action. When the queue has fewer than
10+
-- 3 events, the game is considered stable enough to process API responses. This is a
11+
-- heuristic based on empirical testing to ensure smooth gameplay without delays.
712
local EVENT_QUEUE_THRESHOLD = 3
813
API = {}
914
API.socket = nil

src/lua/utils.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ function utils.table_to_json(obj, depth)
111111
return json.encode(sanitized)
112112
end
113113

114-
-- Load debug
114+
-- Load DebugPlus integration
115+
-- Attempt to load the optional DebugPlus mod (https://github.com/WilsontheWolf/DebugPlus/tree/master).
116+
-- DebugPlus is a Balatro mod that provides additional debugging utilities for mod development,
117+
-- such as custom debug commands and structured logging. It is not required for core functionality
118+
-- and is primarily intended for development and debugging purposes. If the module is unavailable
119+
-- or incompatible, the program will continue to function without it.
115120
local success, dpAPI = pcall(require, "debugplus-api")
116121

117122
if success and dpAPI.isVersionCompatible(1) then

tests/conftest.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,20 @@ def send_and_receive_api_message(
7171

7272

7373
def assert_error_response(response, expected_error_text, expected_context_keys=None):
74-
"""Helper function to assert error response format and content."""
74+
"""
75+
Helper function to assert the format and content of an error response.
76+
77+
Args:
78+
response (dict): The response dictionary to validate. Must contain at least
79+
the keys "error" and "state".
80+
expected_error_text (str): The expected error message text to check within
81+
the "error" field of the response.
82+
expected_context_keys (list, optional): A list of keys expected to be present
83+
in the "context" field of the response, if the "context" field exists.
84+
85+
Raises:
86+
AssertionError: If the response does not match the expected format or content.
87+
"""
7588
assert isinstance(response, dict)
7689
assert "error" in response
7790
assert "state" in response

0 commit comments

Comments
 (0)