File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -732,18 +732,23 @@ API.functions["shop"] = function(args)
732732 return
733733 end
734734
735+
736+ -- Used to ensure dollars and shop have been updated before responding, not inheritly atomic
737+ local dollars_before = G .GAME .dollars
738+ local expected_dollars = dollars_before - card .cost
739+ local shop_size_before = # G .shop_jokers .cards
740+
735741 -- activate the buy button using the UI element handler
736742 G .FUNCS .buy_from_shop (card_buy_button )
737743
738-
739744 -- send response once shop is updated
740745 --- @type PendingRequest
741746 API .pending_requests [" shop" ] = {
742- -- TODO: This sends the update before the dollars have been updated.
743747 condition = function ()
744748 return G .STATE == G .STATES .SHOP
745- and # G .E_MANAGER .queues .base < EVENT_QUEUE_THRESHOLD
746- and G .STATE_COMPLETE
749+ and # G .shop_jokers .cards == shop_size_before - 1
750+ and G .GAME .dollars == expected_dollars
751+ and G .STATE_COMPLETE
747752 end ,
748753 action = function ()
749754 local game_state = utils .get_game_state ()
You can’t perform that action at this time.
0 commit comments