196196API .functions [" get_game_state" ] = function (_ )
197197 --- @type PendingRequest
198198 API .pending_requests [" get_game_state" ] = {
199- condition = utils .COMPLETION_CONDITIONS . get_game_state ,
199+ condition = utils .COMPLETION_CONDITIONS [ " get_game_state" ][ " " ] ,
200200 action = function ()
201201 local game_state = utils .get_game_state ()
202202 API .send_response (game_state )
@@ -217,7 +217,7 @@ API.functions["go_to_menu"] = function(_)
217217
218218 G .FUNCS .go_to_menu ({})
219219 API .pending_requests [" go_to_menu" ] = {
220- condition = utils .COMPLETION_CONDITIONS . go_to_menu ,
220+ condition = utils .COMPLETION_CONDITIONS [ " go_to_menu" ][ " " ] ,
221221 action = function ()
222222 local game_state = utils .get_game_state ()
223223 API .send_response (game_state )
@@ -277,7 +277,7 @@ API.functions["start_run"] = function(args)
277277 -- Defer sending response until the run has started
278278 --- @type PendingRequest
279279 API .pending_requests [" start_run" ] = {
280- condition = utils .COMPLETION_CONDITIONS . start_run ,
280+ condition = utils .COMPLETION_CONDITIONS [ " start_run" ][ " " ] ,
281281 action = function ()
282282 local game_state = utils .get_game_state ()
283283 API .send_response (game_state )
@@ -334,7 +334,7 @@ API.functions["skip_or_select_blind"] = function(args)
334334 G .FUNCS .select_blind (button )
335335 --- @type PendingRequest
336336 API .pending_requests [" skip_or_select_blind" ] = {
337- condition = utils .COMPLETION_CONDITIONS . skip_or_select_blind ,
337+ condition = utils .COMPLETION_CONDITIONS [ " skip_or_select_blind" ][ " select " ] ,
338338 action = function ()
339339 local game_state = utils .get_game_state ()
340340 API .send_response (game_state )
@@ -347,7 +347,7 @@ API.functions["skip_or_select_blind"] = function(args)
347347 G .FUNCS .skip_blind (button )
348348 --- @type PendingRequest
349349 API .pending_requests [" skip_or_select_blind" ] = {
350- condition = utils .COMPLETION_CONDITIONS . skip_or_select_blind ,
350+ condition = utils .COMPLETION_CONDITIONS [ " skip_or_select_blind" ][ " skip " ] ,
351351 action = function ()
352352 local game_state = utils .get_game_state ()
353353 API .send_response (game_state )
@@ -448,7 +448,7 @@ API.functions["play_hand_or_discard"] = function(args)
448448 -- Defer sending response until the run has started
449449 --- @type PendingRequest
450450 API .pending_requests [" play_hand_or_discard" ] = {
451- condition = utils .COMPLETION_CONDITIONS . play_hand_or_discard ,
451+ condition = utils .COMPLETION_CONDITIONS [ " play_hand_or_discard" ][ args . action ] ,
452452 action = function ()
453453 local game_state = utils .get_game_state ()
454454 API .send_response (game_state )
@@ -522,7 +522,7 @@ API.functions["rearrange_hand"] = function(args)
522522
523523 --- @type PendingRequest
524524 API .pending_requests [" rearrange_hand" ] = {
525- condition = utils .COMPLETION_CONDITIONS . rearrange_hand ,
525+ condition = utils .COMPLETION_CONDITIONS [ " rearrange_hand" ][ " " ] ,
526526 action = function ()
527527 local game_state = utils .get_game_state ()
528528 API .send_response (game_state )
@@ -598,7 +598,7 @@ API.functions["rearrange_jokers"] = function(args)
598598
599599 --- @type PendingRequest
600600 API .pending_requests [" rearrange_jokers" ] = {
601- condition = utils .COMPLETION_CONDITIONS . rearrange_jokers ,
601+ condition = utils .COMPLETION_CONDITIONS [ " rearrange_jokers" ][ " " ] ,
602602 action = function ()
603603 local game_state = utils .get_game_state ()
604604 API .send_response (game_state )
@@ -623,7 +623,7 @@ API.functions["cash_out"] = function(_)
623623 G .FUNCS .cash_out ({ config = {} })
624624 --- @type PendingRequest
625625 API .pending_requests [" cash_out" ] = {
626- condition = utils .COMPLETION_CONDITIONS . cash_out ,
626+ condition = utils .COMPLETION_CONDITIONS [ " cash_out" ][ " " ] ,
627627 action = function ()
628628 local game_state = utils .get_game_state ()
629629 API .send_response (game_state )
@@ -659,7 +659,7 @@ API.functions["shop"] = function(args)
659659 G .FUNCS .toggle_shop ({})
660660 --- @type PendingRequest
661661 API .pending_requests [" shop" ] = {
662- condition = utils .COMPLETION_CONDITIONS . shop ,
662+ condition = utils .COMPLETION_CONDITIONS [ " shop" ][ " next_round " ] ,
663663 action = function ()
664664 local game_state = utils .get_game_state ()
665665 API .send_response (game_state )
@@ -756,7 +756,8 @@ API.functions["shop"] = function(args)
756756 API .pending_requests [" shop" ] = {
757757 condition = function ()
758758 -- Purchase action is non-atomic, so we need to check dollars
759- return utils .COMPLETION_CONDITIONS .shop_idle ()
759+ -- TODO: try to use the condition directly
760+ return utils .COMPLETION_CONDITIONS [" shop" ][" buy_card" ]()
760761 and # G .shop_jokers .cards == shop_size_before - 1
761762 and G .GAME .dollars == expected_dollars
762763 end ,
@@ -791,7 +792,7 @@ API.functions["shop"] = function(args)
791792 --- @type PendingRequest
792793 API .pending_requests [" shop" ] = {
793794 condition = function ()
794- return utils .COMPLETION_CONDITIONS . shop_idle ()
795+ return utils .COMPLETION_CONDITIONS [ " shop " ][ " reroll " ] ()
795796 and G .GAME .round_scores
796797 and G .GAME .round_scores .times_rerolled
797798 and G .GAME .round_scores .times_rerolled .amt == times_rerolled_before + 1
0 commit comments