Skip to content

Commit 2cb183d

Browse files
committed
refactor(api): make get_game_state consistent with other endpoints
1 parent 8ca129f commit 2cb183d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/lua/api.lua

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,16 @@ end
207207
---Gets the current game state
208208
---@param _ table Arguments (not used)
209209
API.functions["get_game_state"] = function(_)
210-
local game_state = utils.get_game_state()
211-
API.send_response(game_state)
210+
---@type PendingRequest
211+
API.pending_requests["get_game_state"] = {
212+
condition = function()
213+
return #G.E_MANAGER.queues.base < EVENT_QUEUE_THRESHOLD
214+
end,
215+
action = function()
216+
local game_state = utils.get_game_state()
217+
API.send_response(game_state)
218+
end,
219+
}
212220
end
213221

214222
---Navigates to the main menu.

src/lua/utils.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,10 @@ local EVENT_QUEUE_THRESHOLD = 3
609609
---These are shared between API and LOG systems to ensure consistent timing
610610
---@type table<string, function>
611611
utils.COMPLETION_CONDITIONS = {
612+
get_game_state = function()
613+
return #G.E_MANAGER.queues.base < EVENT_QUEUE_THRESHOLD
614+
end,
615+
612616
go_to_menu = function()
613617
return G.STATE == G.STATES.MENU and G.MAIN_MENU_UI
614618
end,

0 commit comments

Comments
 (0)