Skip to content

Commit f7df990

Browse files
S1M0N38claude
andcommitted
refactor(log): rename params to arguments in logging system
Rename function parameter from 'params' to 'arguments' across Lua logging system and test files to improve code consistency and clarity. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e9814a7 commit f7df990

File tree

5 files changed

+70
-70
lines changed

5 files changed

+70
-70
lines changed

src/lua/log.lua

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ end
1717

1818
---Logs a function call to the JSONL file
1919
---@param function_name string The name of the function being called
20-
---@param params table The parameters passed to the function
21-
function LOG.write(function_name, params)
20+
---@param arguments table The parameters passed to the function
21+
function LOG.write(function_name, arguments)
2222
---@type LogEntry
2323
local log_entry = {
2424
timestamp_ms = math.floor(socket.gettime() * 1000),
2525
["function"] = {
2626
name = function_name,
27-
params = params,
27+
arguments = arguments,
2828
},
2929
-- game_state before the function call
3030
game_state = utils.get_game_state(),
@@ -57,9 +57,9 @@ end
5757
function LOG.hook_go_to_menu()
5858
local original_function = G.FUNCS.go_to_menu
5959
G.FUNCS.go_to_menu = function(args)
60-
local params = {}
60+
local arguments = {}
6161
local name = "go_to_menu"
62-
LOG.write(name, params)
62+
LOG.write(name, arguments)
6363
return original_function(args)
6464
end
6565
sendDebugMessage("Hooked into G.FUNCS.go_to_menu for logging", "LOG")
@@ -77,14 +77,14 @@ function LOG.hook_start_run()
7777
local timestamp = LOG.generate_iso8601_timestamp()
7878
LOG.current_run_file = LOG.mod_path .. "runs/" .. timestamp .. ".jsonl"
7979
sendInfoMessage("Starting new run log: " .. timestamp .. ".jsonl", "LOG")
80-
local params = {
80+
local arguments = {
8181
deck = G.GAME.selected_back.name,
8282
stake = args.stake,
8383
seed = args.seed,
8484
challenge = args.challenge and args.challenge.name,
8585
}
8686
local name = "start_run"
87-
LOG.write(name, params)
87+
LOG.write(name, arguments)
8888
return original_function(game_state, args)
8989
end
9090
sendDebugMessage("Hooked into G.FUNCS.start_run for logging", "LOG")
@@ -98,9 +98,9 @@ end
9898
function LOG.hook_select_blind()
9999
local original_function = G.FUNCS.select_blind
100100
G.FUNCS.select_blind = function(args)
101-
local params = { action = "select" }
101+
local arguments = { action = "select" }
102102
local name = "skip_or_select_blind"
103-
LOG.write(name, params)
103+
LOG.write(name, arguments)
104104
return original_function(args)
105105
end
106106
sendDebugMessage("Hooked into G.FUNCS.select_blind for logging", "LOG")
@@ -110,9 +110,9 @@ end
110110
function LOG.hook_skip_blind()
111111
local original_function = G.FUNCS.skip_blind
112112
G.FUNCS.skip_blind = function(args)
113-
local params = { action = "skip" }
113+
local arguments = { action = "skip" }
114114
local name = "skip_or_select_blind"
115-
LOG.write(name, params)
115+
LOG.write(name, arguments)
116116
return original_function(args)
117117
end
118118
sendDebugMessage("Hooked into G.FUNCS.skip_blind for logging", "LOG")
@@ -132,9 +132,9 @@ function LOG.hook_play_cards_from_highlighted()
132132
table.insert(cards, i - 1) -- Adjust for 0-based indexing
133133
end
134134
end
135-
local params = { action = "play_hand", cards = cards }
135+
local arguments = { action = "play_hand", cards = cards }
136136
local name = "play_hand_or_discard"
137-
LOG.write(name, params)
137+
LOG.write(name, arguments)
138138
return original_function(args)
139139
end
140140
sendDebugMessage("Hooked into G.FUNCS.play_cards_from_highlighted for logging", "LOG")
@@ -150,9 +150,9 @@ function LOG.hook_discard_cards_from_highlighted()
150150
table.insert(cards, i - 1) -- Adjust for 0-based indexing
151151
end
152152
end
153-
local params = { action = "discard", cards = cards }
153+
local arguments = { action = "discard", cards = cards }
154154
local name = "play_hand_or_discard"
155-
LOG.write(name, params)
155+
LOG.write(name, arguments)
156156
return original_function(args)
157157
end
158158
sendDebugMessage("Hooked into G.FUNCS.discard_cards_from_highlighted for logging", "LOG")
@@ -166,9 +166,9 @@ end
166166
function LOG.hook_cash_out()
167167
local original_function = G.FUNCS.cash_out
168168
G.FUNCS.cash_out = function(args)
169-
local params = {}
169+
local arguments = {}
170170
local name = "cash_out"
171-
LOG.write(name, params)
171+
LOG.write(name, arguments)
172172
return original_function(args)
173173
end
174174
sendDebugMessage("Hooked into G.FUNCS.cash_out for logging", "LOG")
@@ -182,9 +182,9 @@ end
182182
function LOG.hook_toggle_shop()
183183
local original_function = G.FUNCS.toggle_shop
184184
G.FUNCS.toggle_shop = function(args)
185-
local params = { action = "next_round" }
185+
local arguments = { action = "next_round" }
186186
local name = "shop"
187-
LOG.write(name, params)
187+
LOG.write(name, arguments)
188188
return original_function(args)
189189
end
190190
sendDebugMessage("Hooked into G.FUNCS.toggle_shop for logging", "LOG")

src/lua/types.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123

124124
---@class LogEntry
125125
---@field timestamp_ms number Timestamp in milliseconds since epoch
126-
---@field function {name: string, params: table} Function call information
126+
---@field function {name: string, arguments: table} Function call information
127127
---@field game_state GameStateResponse Game state at time of logging
128128

129129
-- =============================================================================

tests/lua/test_runs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def test_replay_run(self, tcp_client: socket.socket, jsonl_file: Path) -> None:
5353

5454
# Call the API function with recorded parameters
5555
actual_game_state = send_and_receive_api_message(
56-
tcp_client, function_call["name"], function_call["params"]
56+
tcp_client, function_call["name"], function_call["arguments"]
5757
)
5858

5959
# Compare with the game_state from the next step (if it exists)
@@ -64,7 +64,7 @@ def test_replay_run(self, tcp_client: socket.socket, jsonl_file: Path) -> None:
6464
# Assert complete game state equality
6565
assert actual_game_state == expected_game_state, (
6666
f"Game state mismatch at step {step_num + 1} in {jsonl_file.name}\n"
67-
f"Function: {function_call['name']}({function_call['params']})\n"
67+
f"Function: {function_call['name']}({function_call['arguments']})\n"
6868
f"Expected: {expected_game_state}\n"
6969
f"Actual: {actual_game_state}"
7070
)

0 commit comments

Comments
 (0)