@@ -26,8 +26,8 @@ function Botlogger.getfilename(settings)
2626end
2727
2828function Botlogger .logbotdecision (...)
29- local _action , _arg1 , _arg2 = ...
30-
29+ local _args = { ... }
30+ local _action = table.remove ( _args , 1 )
3131 local _logstring = ' '
3232
3333 if _action then
@@ -38,19 +38,14 @@ function Botlogger.logbotdecision(...)
3838 end
3939 end
4040
41- if _arg1 then
42- if type (_arg1 ) == ' number' then
43- _logstring = _logstring .. ' ,' .. tostring (_arg1 )
44- elseif type (_arg1 ) == ' table' then
45- for i = 1 , # _arg1 do
46- _logstring = _logstring .. ' ,' .. tostring (_arg1 [i ])
41+ for i = 1 , # _args do
42+ _logstring = _logstring .. ' |'
43+ if type (_args [i ]) == ' table' then
44+ for j = 1 , # _args [i ] do
45+ _logstring = _logstring .. ' ,' .. tostring (_args [i ][j ])
4746 end
48- end
49- end
50-
51- if _arg2 then -- This is only the case for select_booster_action
52- for i = 1 , # _arg2 do
53- _logstring = _logstring .. ' ,' .. tostring (_arg2 [i ])
47+ else
48+ _logstring = _logstring .. tostring (_args [i ])
5449 end
5550 end
5651
@@ -118,7 +113,6 @@ function Botlogger.inithooks()
118113
119114 elseif Bot .SETTINGS .api == false then
120115 List .pushright (Botlogger [' q_' .. k ], _action )
121- sendDebugMessage (' q_' .. k .. " is not empty. Returning Bot.ACTIONS.PASS" )
122116 return Bot .ACTIONS .PASS
123117
124118 -- We don't care about action order for the API.
@@ -130,10 +124,7 @@ function Botlogger.inithooks()
130124 -- Return an action of "PASS" when the API is not enabled.
131125 -- When API is enabled, nothing is returned, and the system waits for the queue to be populated
132126 if Bot .SETTINGS .api == false then
133- sendDebugMessage (' q_' .. k .. " is empty. Returning Bot.ACTIONS.PASS" )
134127 return Bot .ACTIONS .PASS
135- else
136- sendDebugMessage (' q_' .. k .. " is empty. Waiting for API to populate queue..." )
137128 end
138129 end
139130 end
@@ -150,77 +141,14 @@ function Botlogger.inithooks()
150141 local _num_action = 0
151142 for line in io.lines (_replayfile ) do
152143 _num_action = _num_action + 1
153- local _action = { }
154-
155- local _splitstring = { }
156- local _i = 1
157- for str in string.gmatch (line , ' ([^,]+)' ) do
158- _splitstring [_i ] = str
159- _i = _i + 1
160- end
161-
162- _action [1 ] = Bot .ACTIONS [_splitstring [1 ]]
163144
164- if _action [1 ] == Bot .ACTIONS .SELECT_BLIND or _action [1 ] == Bot .ACTIONS .SKIP_BLIND then
165- List .pushleft (Botlogger .q_skip_or_select_blind , { _num_action , _action })
166- elseif _action [1 ] == Bot .ACTIONS .PLAY_HAND or _action [1 ] == Bot .ACTIONS .DISCARD_HAND then
167- local _cards = { }
168- for i = 2 , # _splitstring do
169- _cards [i - 1 ] = tonumber (_splitstring [i ])
170- end
171- _action [2 ] = _cards
172-
173- List .pushleft (Botlogger .q_select_cards_from_hand , { _num_action , _action })
174- elseif _action [1 ] == Bot .ACTIONS .END_SHOP or _action [1 ] == Bot .ACTIONS .REROLL_SHOP or _action [1 ] == Bot .ACTIONS .BUY_CARD or _action [1 ] == Bot .ACTIONS .BUY_VOUCHER or _action [1 ] == Bot .ACTIONS .BUY_BOOSTER then
175- if # _splitstring > 1 then
176- _action [2 ] = {tonumber (_splitstring [2 ])}
177- end
178- List .pushleft (Botlogger .q_select_shop_action , { _num_action , _action })
179- elseif _action [1 ] == Bot .ACTIONS .SELECT_BOOSTER_CARD or _action [1 ] == Bot .ACTIONS .SKIP_BOOSTER_PACK then
180- if # _splitstring > 1 then
181- _action [2 ] = {tonumber (_splitstring [2 ])}
182- end
183-
184- if # _splitstring > 2 then
185- local _cards = { }
186- for i = 3 , # _splitstring do
187- _cards [i - 2 ] = tonumber (_splitstring [i ])
188- end
189- _action [3 ] = _cards
190- end
191- List .pushleft (Botlogger .q_select_booster_action , { _num_action , _action })
192- elseif _action [1 ] == Bot .ACTIONS .SELL_JOKER then
193- local _cards = { }
194- for i = 2 , # _splitstring do
195- _cards [i - 1 ] = tonumber (_splitstring [i ])
196- end
197- _action [2 ] = _cards
198- List .pushleft (Botlogger .q_sell_jokers , { _num_action , _action })
199- elseif _action [1 ] == Bot .ACTIONS .USE_CONSUMABLE or _action [1 ] == Bot .ACTIONS .SELL_CONSUMABLE then
200- _action [2 ] = {tonumber (_splitstring [2 ])}
201- List .pushleft (Botlogger .q_use_or_sell_consumables , { _num_action , _action })
202- elseif _action [1 ] == Bot .ACTIONS .REARRANGE_JOKERS then
203- local _cards = { }
204- for i = 2 , # _splitstring do
205- _cards [i - 1 ] = tonumber (_splitstring [i ])
206- end
207- _action [2 ] = _cards
208- List .pushleft (Botlogger .q_rearrange_jokers , { _num_action , _action })
209- elseif _action [1 ] == Bot .ACTIONS .REARRANGE_CONSUMABLES then
210- local _cards = { }
211- for i = 2 , # _splitstring do
212- _cards [i - 1 ] = tonumber (_splitstring [i ])
213- end
214- _action [2 ] = _cards
215- List .pushleft (Botlogger .q_rearrange_consumables , { _num_action , _action })
216- elseif _action [1 ] == Bot .ACTIONS .REARRANGE_HAND then
217- local _cards = { }
218- for i = 2 , # _splitstring do
219- _cards [i - 1 ] = tonumber (_splitstring [i ])
220- end
221- _action [2 ] = _cards
222- List .pushleft (Botlogger .q_rearrange_hand , { _num_action , _action })
145+ local _action = BalatrobotAPI .parseaction (line )
146+ sendDebugMessage (line )
147+ local _params = Bot .ACTIONPARAMS [_action [1 ]]
148+ for i = 2 , # _action do
149+ sendDebugMessage (tostring (_action [i ][1 ]))
223150 end
151+ List .pushleft (Botlogger [' q_' .. _params .func ], { _num_action , _action })
224152 end
225153 end
226154 elseif Bot .SETTINGS .replay == false then
0 commit comments