Skip to content

Commit 517f314

Browse files
committed
feat(api): add cashout API function
1 parent 988fc4a commit 517f314

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/lua/api.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,27 @@ API.functions["play_hand_or_discard"] = function(args)
279279
}
280280
end
281281

282+
API.functions["cash_out"] = function(args)
283+
-- Validate current game state is appropriate for cash out
284+
if G.STATE ~= G.STATES.ROUND_EVAL then
285+
sendErrorMessage("Cannot cash out when not in shop. Current state: " .. tostring(G.STATE), "BALATROBOT")
286+
API.send_response({ error = "Cannot cash out when not in shop", state = G.STATE })
287+
return
288+
end
289+
290+
G.FUNCS.cash_out({ config = {} })
291+
API.pending_requests["cash_out"] = {
292+
condition = function()
293+
return G.STATE == G.STATES.SHOP and #G.E_MANAGER.queues.base < 3 and G.STATE_COMPLETE
294+
end,
295+
action = function(args)
296+
local game_state = utils.get_game_state()
297+
API.send_response(game_state)
298+
end,
299+
args = args,
300+
}
301+
end
302+
282303
API.functions["select_booster_action"] = function(args)
283304
-- TODO: implement
284305
end

0 commit comments

Comments
 (0)