11# -*- coding: utf-8 - Lizier -*-
22from ast import Return
3+ from pickle import TRUE
34from cv2 import cv2
45
56from captcha .solveCaptcha import solveCaptcha
@@ -220,21 +221,22 @@ def playSPG():
220221
221222def removeSpaceships ():
222223 time .sleep (2 )
223- global bot_working
224-
224+
225225 while True :
226226 if (CheckTimeRestartGame ()):
227227 break
228228
229229 if (checkClose ()):
230230 break
231231
232+ if (CheckBotWork () == False ):
233+ break
234+
232235 if (checkHome ()):
233236 buttons = positions (images ['spg-x' ], threshold = ct ['remove_to_work_btn' ])
234237
235238 if len (buttons ) > 0 :
236- bot_working = True
237-
239+
238240 # Havia criado com objetivo de clicar nos X de baixo para cima
239241 # e para conseguir fazer isso eu havia criado um while para posicionar os index ao contrario.
240242 # \o/ porem descobri o "reversed" que faz isso certinho.
@@ -249,8 +251,20 @@ def removeSpaceships():
249251 # pyautogui.click()
250252
251253 for (x , y , w , h ) in reversed (buttons ):
252- moveToWithRandomness (x + (w / 2 ),y + (h / 2 ),ct ['mouse_speed' ])
253- pyautogui .click ()
254+ if (restrictArea (x = x ,y = y ) == False ):
255+ moveToWithRandomness (x + (w / 2 ),y + (h / 2 ),ct ['mouse_speed' ])
256+ pyautogui .click ()
257+
258+ if (CheckTimeRestartGame ()):
259+ break
260+
261+ if (checkClose ()):
262+ break
263+
264+ if (CheckBotWork () == False ):
265+ break
266+ else :
267+ logger ('Click restricted Area Eixo' )
254268
255269 if len (buttons ) == 0 :
256270 break
@@ -273,28 +287,31 @@ def clickButtonsFight():
273287 ajustY = 0
274288
275289 qtd_send_spaceships = ct ['qtd_send_spaceships' ]
276-
277290
278- for (x , y , w , h ) in reversed (buttons ): #Adjust for click button a little more intelligent
279- moveToWithRandomness (x + ajustX + (w / 2 ),y + ajustY + (h / 2 ),ct ['mouse_speed' ])
280- pyautogui .click ()
281- global hero_clicks
282- hero_clicks = hero_clicks + 1
291+ for (x , y , w , h ) in reversed (buttons ): #Adjust for click button a little more intelligent
283292
284- global bot_working
285- bot_working = True
293+ tx = x + ajustX
294+ ty = y + ajustY
295+
296+ if restrictArea (x = tx ,y = ty ) == False :
297+ moveToWithRandomness (tx + (w / 2 ),ty + (h / 2 ),ct ['mouse_speed' ])
298+ pyautogui .click ()
299+ global hero_clicks
300+ hero_clicks = hero_clicks + 1
286301
287- if hero_clicks >= qtd_send_spaceships :
288- logger ('Finish Click Hero' )
289- return - 1
302+ if hero_clicks >= qtd_send_spaceships :
303+ logger ('Finish Click Hero' )
304+ return - 1
290305
291- if (ct ['send_incomplete_team' ]):
292- if hero_clicks > 0 :
293- if hero_clicks >= ct ['send_space_min' ]:
294- if count_reloadSpacheship >= ct ['qtd_check_reloadSpacheship' ]:
295- logger ('Send incomplet team' )
296- hero_clicks = qtd_send_spaceships
297- return - 1
306+ if (ct ['send_incomplete_team' ]):
307+ if hero_clicks > 0 :
308+ if hero_clicks >= ct ['send_space_min' ]:
309+ if count_reloadSpacheship >= ct ['qtd_check_reloadSpacheship' ]:
310+ logger ('Send incomplet team' )
311+ hero_clicks = qtd_send_spaceships
312+ return - 1
313+ else :
314+ logger ('Click restricted Area' )
298315
299316 return len (buttons )
300317
@@ -338,7 +355,9 @@ def refreshSpaceships(qtd):
338355
339356 if (checkHome ()):
340357 buttonsClicked = clickButtonsFight ()
341- CheckBotWork ()
358+
359+ if (CheckBotWork () == False ):
360+ break
342361
343362 if buttonsClicked == 0 :
344363 empty_scrolls_attempts = empty_scrolls_attempts - 1
@@ -521,8 +540,18 @@ def CheckBotWork():
521540 if now - last ["CheckBotWork" ] > addRandomness (ct ['Check_Bot_Work' ]* 60 ):
522541 logger ('Bot is not performing any action. The Game will be restarted.' )
523542 refreshPage ()
543+ return False
524544 else :
525545 last ["CheckBotWork" ] = now
546+ return True
547+
548+ def restrictArea (x ,y ):
549+ if y >= 612 :
550+ logger ('Eixo y {}' .format (y ))
551+ return True
552+ else :
553+ return False
554+
526555
527556def main ():
528557 time .sleep (5 )
0 commit comments