@@ -9,8 +9,20 @@ BalatrobotAPI.socket = nil
99BalatrobotAPI .waitingFor = nil
1010BalatrobotAPI .waitingForAction = true
1111
12+ -- Action queues for Python bot commands
13+ BalatrobotAPI .q_skip_or_select_blind = nil
14+ BalatrobotAPI .q_select_cards_from_hand = nil
15+ BalatrobotAPI .q_select_shop_action = nil
16+ BalatrobotAPI .q_select_booster_action = nil
17+ BalatrobotAPI .q_sell_jokers = nil
18+ BalatrobotAPI .q_rearrange_jokers = nil
19+ BalatrobotAPI .q_use_or_sell_consumables = nil
20+ BalatrobotAPI .q_rearrange_consumables = nil
21+ BalatrobotAPI .q_rearrange_hand = nil
22+ BalatrobotAPI .q_start_run = nil
23+
1224function BalatrobotAPI .notifyapiclient ()
13- -- TODO Generate gamestate json object
25+ -- Generate gamestate json object
1426 local _gamestate = Utils .getGamestate ()
1527 _gamestate .waitingFor = BalatrobotAPI .waitingFor
1628 sendDebugMessage (" WaitingFor " .. tostring (BalatrobotAPI .waitingFor ))
3547
3648function BalatrobotAPI .queueaction (action )
3749 local _params = Bot .ACTIONPARAMS [action [1 ]]
38- List .pushleft (Botlogger [" q_" .. _params .func ], { 0 , action })
50+ List .pushleft (BalatrobotAPI [" q_" .. _params .func ], { 0 , action })
3951end
4052
4153function BalatrobotAPI .update (dt )
@@ -76,6 +88,18 @@ function BalatrobotAPI.update(dt)
7688end
7789
7890function BalatrobotAPI .init ()
91+ -- Initialize action queues for Python bot commands
92+ BalatrobotAPI .q_skip_or_select_blind = List .new ()
93+ BalatrobotAPI .q_select_cards_from_hand = List .new ()
94+ BalatrobotAPI .q_select_shop_action = List .new ()
95+ BalatrobotAPI .q_select_booster_action = List .new ()
96+ BalatrobotAPI .q_sell_jokers = List .new ()
97+ BalatrobotAPI .q_rearrange_jokers = List .new ()
98+ BalatrobotAPI .q_use_or_sell_consumables = List .new ()
99+ BalatrobotAPI .q_rearrange_consumables = List .new ()
100+ BalatrobotAPI .q_rearrange_hand = List .new ()
101+ BalatrobotAPI .q_start_run = List .new ()
102+
79103 love .update = Hook .addcallback (love .update , BalatrobotAPI .update )
80104
81105 -- Tell the game engine that every frame is 8/60 seconds long
@@ -128,48 +152,47 @@ function BalatrobotAPI.init()
128152 end
129153 end
130154
131- if Bot .SETTINGS .api == true then
132- Middleware .c_play_hand = Hook .addbreakpoint (Middleware .c_play_hand , function ()
133- BalatrobotAPI .waitingFor = " select_cards_from_hand"
134- BalatrobotAPI .waitingForAction = true
135- end )
136- Middleware .c_select_blind = Hook .addbreakpoint (Middleware .c_select_blind , function ()
137- BalatrobotAPI .waitingFor = " skip_or_select_blind"
138- BalatrobotAPI .waitingForAction = true
139- end )
140- Middleware .c_choose_booster_cards = Hook .addbreakpoint (Middleware .c_choose_booster_cards , function ()
141- BalatrobotAPI .waitingFor = " select_booster_action"
142- BalatrobotAPI .waitingForAction = true
143- end )
144- Middleware .c_shop = Hook .addbreakpoint (Middleware .c_shop , function ()
145- BalatrobotAPI .waitingFor = " select_shop_action"
146- BalatrobotAPI .waitingForAction = true
147- end )
148- Middleware .c_rearrange_hand = Hook .addbreakpoint (Middleware .c_rearrange_hand , function ()
149- BalatrobotAPI .waitingFor = " rearrange_hand"
150- BalatrobotAPI .waitingForAction = true
151- end )
152- Middleware .c_rearrange_consumables = Hook .addbreakpoint (Middleware .c_rearrange_consumables , function ()
153- BalatrobotAPI .waitingFor = " rearrange_consumables"
154- BalatrobotAPI .waitingForAction = true
155- end )
156- Middleware .c_use_or_sell_consumables = Hook .addbreakpoint (Middleware .c_use_or_sell_consumables , function ()
157- BalatrobotAPI .waitingFor = " use_or_sell_consumables"
158- BalatrobotAPI .waitingForAction = true
159- end )
160- Middleware .c_rearrange_jokers = Hook .addbreakpoint (Middleware .c_rearrange_jokers , function ()
161- BalatrobotAPI .waitingFor = " rearrange_jokers"
162- BalatrobotAPI .waitingForAction = true
163- end )
164- Middleware .c_sell_jokers = Hook .addbreakpoint (Middleware .c_sell_jokers , function ()
165- BalatrobotAPI .waitingFor = " sell_jokers"
166- BalatrobotAPI .waitingForAction = true
167- end )
168- Middleware .c_start_run = Hook .addbreakpoint (Middleware .c_start_run , function ()
169- BalatrobotAPI .waitingFor = " start_run"
170- BalatrobotAPI .waitingForAction = true
171- end )
172- end
155+ -- Set up waiting states for Python bot
156+ Middleware .c_play_hand = Hook .addbreakpoint (Middleware .c_play_hand , function ()
157+ BalatrobotAPI .waitingFor = " select_cards_from_hand"
158+ BalatrobotAPI .waitingForAction = true
159+ end )
160+ Middleware .c_select_blind = Hook .addbreakpoint (Middleware .c_select_blind , function ()
161+ BalatrobotAPI .waitingFor = " skip_or_select_blind"
162+ BalatrobotAPI .waitingForAction = true
163+ end )
164+ Middleware .c_choose_booster_cards = Hook .addbreakpoint (Middleware .c_choose_booster_cards , function ()
165+ BalatrobotAPI .waitingFor = " select_booster_action"
166+ BalatrobotAPI .waitingForAction = true
167+ end )
168+ Middleware .c_shop = Hook .addbreakpoint (Middleware .c_shop , function ()
169+ BalatrobotAPI .waitingFor = " select_shop_action"
170+ BalatrobotAPI .waitingForAction = true
171+ end )
172+ Middleware .c_rearrange_hand = Hook .addbreakpoint (Middleware .c_rearrange_hand , function ()
173+ BalatrobotAPI .waitingFor = " rearrange_hand"
174+ BalatrobotAPI .waitingForAction = true
175+ end )
176+ Middleware .c_rearrange_consumables = Hook .addbreakpoint (Middleware .c_rearrange_consumables , function ()
177+ BalatrobotAPI .waitingFor = " rearrange_consumables"
178+ BalatrobotAPI .waitingForAction = true
179+ end )
180+ Middleware .c_use_or_sell_consumables = Hook .addbreakpoint (Middleware .c_use_or_sell_consumables , function ()
181+ BalatrobotAPI .waitingFor = " use_or_sell_consumables"
182+ BalatrobotAPI .waitingForAction = true
183+ end )
184+ Middleware .c_rearrange_jokers = Hook .addbreakpoint (Middleware .c_rearrange_jokers , function ()
185+ BalatrobotAPI .waitingFor = " rearrange_jokers"
186+ BalatrobotAPI .waitingForAction = true
187+ end )
188+ Middleware .c_sell_jokers = Hook .addbreakpoint (Middleware .c_sell_jokers , function ()
189+ BalatrobotAPI .waitingFor = " sell_jokers"
190+ BalatrobotAPI .waitingForAction = true
191+ end )
192+ Middleware .c_start_run = Hook .addbreakpoint (Middleware .c_start_run , function ()
193+ BalatrobotAPI .waitingFor = " start_run"
194+ BalatrobotAPI .waitingForAction = true
195+ end )
173196end
174197
175198return BalatrobotAPI
0 commit comments