Skip to content

Commit 6bcab8a

Browse files
S1M0N38claude
andcommitted
feat(api): add shop action support with next_round functionality
- Add shop function to handle shop state actions - Implement next_round action to transition from shop to blind select - Add ShopActionArgs type definition with action field - Include validation for shop state before action execution - Add pending request handling for state transitions Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 50794a5 commit 6bcab8a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/lua/api.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,35 @@ API.functions["cash_out"] = function(_)
334334
}
335335
end
336336

337+
---Selects an action for shop
338+
---@param args ShopActionArgs The shop action to perform
339+
API.functions["shop"] = function(args)
340+
-- Validate current game state is appropriate for shop
341+
if G.STATE ~= G.STATES.SHOP then
342+
API.send_error_response("Cannot select shop action when not in shop", { current_state = G.STATE })
343+
return
344+
end
345+
346+
local action = args.action
347+
if action == "next_round" then
348+
G.FUNCS.toggle_shop({})
349+
API.pending_requests["shop"] = {
350+
condition = function()
351+
return G.STATE == G.STATES.BLIND_SELECT
352+
and #G.E_MANAGER.queues.base < EVENT_QUEUE_THRESHOLD
353+
and G.STATE_COMPLETE
354+
end,
355+
action = function()
356+
local game_state = utils.get_game_state()
357+
API.send_response(game_state)
358+
end,
359+
}
360+
else
361+
API.send_error_response("Invalid action arg for shop", { action = action })
362+
return
363+
end
364+
end
365+
337366
---Selects an action for booster packs (TODO implement)
338367
---@param _ table Arguments
339368
API.functions["select_booster_action"] = function(_)

src/lua/types.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@
4646
---@field action "play_hand" | "discard" The action to perform
4747
---@field cards number[] Array of card indices (0-based)
4848

49+
---@class ShopActionArgs
50+
---@field action "next_round" The action to perform
51+
52+
-- TODO: add the other actions "reroll" | "buy" | "buy_and_use" | "redeem" | "open"
53+
--@field item number? The item to buy/buy_and_use/redeem/open (0-based)
54+
4955
-- =============================================================================
5056
-- Main API Module (defined in api.lua)
5157
-- =============================================================================

0 commit comments

Comments
 (0)