Skip to content

Commit e82560a

Browse files
committed
Update index.py
1 parent 46a8534 commit e82560a

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

index.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@
5454
count_nexList = 1
5555
bot_working = False
5656

57+
last = {
58+
"lessPosition":[],
59+
"CheckInitialPage":0,
60+
"CheckInicialCube":0,
61+
"CheckBotWork":0,
62+
}
63+
5764

5865

5966
def addRandomness(n, randomn_factor_size=None):
@@ -317,7 +324,8 @@ def refreshSpaceships(qtd):
317324
break
318325

319326
buttonsClicked = clickButtonsFight()
320-
327+
CheckBotWork()
328+
321329
if buttonsClicked == 0:
322330
empty_scrolls_attempts = empty_scrolls_attempts - 1
323331
scroll(-cda)
@@ -487,19 +495,34 @@ def checkProcessing():
487495
if len(positions(images['spg-processing'], threshold=ct['commom_position'])) > 0:
488496
return True
489497

498+
def CheckBotWork():
499+
global bot_working
500+
global last
501+
now = time.time()
502+
503+
if bot_working == False:
504+
logger('Bot is not performing any action.')
505+
if now - last["CheckBotWork"] > addRandomness(ct['Check_Bot_Work']*60):
506+
logger('Bot is not performing any action. The Game will be restarted.')
507+
refreshPage()
508+
else:
509+
last["CheckBotWork"] = now
510+
490511

491512
def main():
492513
time.sleep(5)
493514
t = c['time_intervals']
494515

495-
516+
global last
496517
last = {
497518
"lessPosition":[],
498519
"CheckInitialPage":0,
499520
"CheckInicialCube":0,
500521
"CheckBotWork":0,
501522
}
502523

524+
last["CheckBotWork"] = time.time()
525+
503526
while True:
504527
global bot_working
505528
bot_working = False
@@ -575,13 +598,7 @@ def main():
575598
if(CheckTimeRestartGame()):
576599
bot_working = True
577600

578-
if bot_working == False:
579-
logger('Bot is not performing any action.')
580-
if now - last["CheckBotWork"] > addRandomness(ct['Check_Bot_Work']*60):
581-
logger('Bot is not performing any action. The Game will be restarted.')
582-
refreshPage()
583-
else:
584-
last["CheckBotWork"] = now
601+
CheckBotWork()
585602
main()
586603

587604

0 commit comments

Comments
 (0)