@@ -642,11 +642,7 @@ API.functions["shop"] = function(args)
642642 elseif action == " buy_card" then
643643 -- Validate index argument
644644 if args .index == nil then
645- API .send_error_response (
646- " Missing required field: index" ,
647- ERROR_CODES .MISSING_ARGUMENTS ,
648- { field = " index" }
649- )
645+ API .send_error_response (" Missing required field: index" , ERROR_CODES .MISSING_ARGUMENTS , { field = " index" })
650646 return
651647 end
652648
@@ -699,7 +695,12 @@ API.functions["shop"] = function(args)
699695 end
700696 elseif card .ability .set == " Planet" or card .ability .set == " Tarot" or card .ability .set == " Spectral" then
701697 -- Check for free consumable slots (typo is intentional, present in source)
702- if G .GAME .consumeables and G .GAME .consumeables .cards and G .GAME .consumeables .card_limit and # G .GAME .consumeables .cards >= G .GAME .consumeables .card_limit then
698+ if
699+ G .GAME .consumeables
700+ and G .GAME .consumeables .cards
701+ and G .GAME .consumeables .card_limit
702+ and # G .GAME .consumeables .cards >= G .GAME .consumeables .card_limit
703+ then
703704 API .send_error_response (
704705 " Can't purchase consumable card, consumable slots are full" ,
705706 ERROR_CODES .INVALID_ACTION ,
@@ -708,23 +709,17 @@ API.functions["shop"] = function(args)
708709 end
709710 end
710711
711-
712712 -- Validate that some purchase button exists (should be a redundant check)
713713 local card_buy_button = card .children .buy_button and card .children .buy_button .definition
714714 if not card_buy_button then
715- API .send_error_response (
716- " Card has no buy button" ,
717- ERROR_CODES .INVALID_GAME_STATE ,
718- { index = args .index }
719- )
715+ API .send_error_response (" Card has no buy button" , ERROR_CODES .INVALID_GAME_STATE , { index = args .index })
720716 return
721717 end
722718
723-
724719 -- Used to ensure dollars and shop have been updated before responding, not inheritly atomic
725- local dollars_before = G .GAME .dollars
726- local expected_dollars = dollars_before - card .cost
727- local shop_size_before = # G .shop_jokers .cards
720+ local dollars_before = G .GAME .dollars
721+ local expected_dollars = dollars_before - card .cost
722+ local shop_size_before = # G .shop_jokers .cards
728723
729724 -- activate the buy button using the UI element handler
730725 G .FUNCS .buy_from_shop (card_buy_button )
@@ -734,9 +729,9 @@ API.functions["shop"] = function(args)
734729 API .pending_requests [" shop" ] = {
735730 condition = function ()
736731 return G .STATE == G .STATES .SHOP
737- and # G .shop_jokers .cards == shop_size_before - 1
738- and G .GAME .dollars == expected_dollars
739- and G .STATE_COMPLETE
732+ and # G .shop_jokers .cards == shop_size_before - 1
733+ and G .GAME .dollars == expected_dollars
734+ and G .STATE_COMPLETE
740735 end ,
741736 action = function ()
742737 local game_state = utils .get_game_state ()
0 commit comments