@@ -172,6 +172,8 @@ def refreshPage():
172172 pyautogui .hotkey ('ctrl' ,'f5' )
173173 time .sleep (1.5 )
174174 pyautogui .hotkey ('shift' ,'f5' )
175+ time .sleep (1.5 )
176+ pyautogui .hotkey ('ctrl' ,'shift' ,'r' )
175177
176178 time .sleep (ct ['timeW_after_refreshPage' ])
177179 processLogin ()
@@ -221,32 +223,36 @@ def removeSpaceships():
221223 global bot_working
222224
223225 while True :
224- buttons = positions (images ['spg-x' ], threshold = ct ['remove_to_work_btn' ])
226+ if (CheckTimeRestartGame ()):
227+ break
228+
229+ if (checkHome ()):
230+ buttons = positions (images ['spg-x' ], threshold = ct ['remove_to_work_btn' ])
225231
226- if len (buttons ) > 0 :
227- bot_working = True
232+ if len (buttons ) > 0 :
233+ bot_working = True
228234
229- # Havia criado com objetivo de clicar nos X de baixo para cima
230- # e para conseguir fazer isso eu havia criado um while para posicionar os index ao contrario.
231- # \o/ porem descobri o "reversed" que faz isso certinho.
235+ # Havia criado com objetivo de clicar nos X de baixo para cima
236+ # e para conseguir fazer isso eu havia criado um while para posicionar os index ao contrario.
237+ # \o/ porem descobri o "reversed" que faz isso certinho.
232238
233- # index = len(buttons)
234- # while index > 0:
235- # index -= 1
236- # buttonsNewOrder.append(buttons[index])
239+ # index = len(buttons)
240+ # while index > 0:
241+ # index -= 1
242+ # buttonsNewOrder.append(buttons[index])
237243
238- # for (x, y, w, h) in buttonsNewOrder:
239- # moveToWithRandomness(x+(w/2),y+(h/2),1)
240- # pyautogui.click()
244+ # for (x, y, w, h) in buttonsNewOrder:
245+ # moveToWithRandomness(x+(w/2),y+(h/2),1)
246+ # pyautogui.click()
241247
242- for (x , y , w , h ) in reversed (buttons ):
243- moveToWithRandomness (x + (w / 2 ),y + (h / 2 ),ct ['mouse_speed' ])
244- pyautogui .click ()
248+ for (x , y , w , h ) in reversed (buttons ):
249+ moveToWithRandomness (x + (w / 2 ),y + (h / 2 ),ct ['mouse_speed' ])
250+ pyautogui .click ()
245251
246- if len (buttons ) == 0 :
247- break
252+ if len (buttons ) == 0 :
253+ break
248254
249- if ( CheckTimeRestartGame ()) :
255+ else :
250256 break
251257
252258def clickButtonsFight ():
@@ -283,7 +289,7 @@ def clickButtonsFight():
283289 if hero_clicks > 0 :
284290 if hero_clicks >= ct ['send_space_min' ]:
285291 if count_reloadSpacheship >= ct ['qtd_check_reloadSpacheship' ]:
286- logger ('Enviando time mesmo incompleto ' )
292+ logger ('Send incomplet team ' )
287293 hero_clicks = qtd_send_spaceships
288294 return - 1
289295
@@ -306,7 +312,11 @@ def refreshSpaceships(qtd):
306312
307313 empty_scrolls_attempts = qtd_send_spaceships
308314
309- checkClose ()
315+ if (checkClose ()):
316+ return False
317+
318+ if (CheckTimeRestartGame ()):
319+ return False
310320
311321 if qtd > 0 :
312322 hero_clicks = qtd
@@ -323,21 +333,24 @@ def refreshSpaceships(qtd):
323333 if (checkClose ()):
324334 break
325335
326- buttonsClicked = clickButtonsFight ()
327- CheckBotWork ()
336+ if (checkHome ()):
337+ buttonsClicked = clickButtonsFight ()
338+ CheckBotWork ()
328339
329- if buttonsClicked == 0 :
330- empty_scrolls_attempts = empty_scrolls_attempts - 1
331- scroll (- cda )
332- else :
333- if buttonsClicked == - 1 :
334- empty_scrolls_attempts = 0
340+ if buttonsClicked == 0 :
341+ empty_scrolls_attempts = empty_scrolls_attempts - 1
342+ scroll (- cda )
335343 else :
336- if buttonsClicked > 0 :
337- empty_scrolls_attempts = empty_scrolls_attempts + 1
344+ if buttonsClicked == - 1 :
345+ empty_scrolls_attempts = 0
346+ else :
347+ if buttonsClicked > 0 :
348+ empty_scrolls_attempts = empty_scrolls_attempts + 1
338349
339- time .sleep (2 )
340- logger ('💪 {} Spaceships sent to Fight' .format (hero_clicks ))
350+ time .sleep (2 )
351+ logger ('💪 {} Spaceships sent to Fight' .format (hero_clicks ))
352+ else :
353+ break
341354
342355 if hero_clicks == qtd_send_spaceships :
343356 empty_scrolls_attempts = 0
@@ -393,7 +406,7 @@ def endFight():
393406 if len (positions (images ['spg-processing' ], threshold = ct ['commom_position' ])) > 0 :
394407 time .sleep (ct ['check_processing_time' ])
395408
396- if len ( positions ( images [ 'spg-go-to-boss' ], threshold = ct [ 'base_position' ])) > 0 :
409+ if ( checkHome ()) :
397410 removeSpaceships ()
398411 time .sleep (1 )
399412 refreshSpaceships (0 )
0 commit comments