Skip to content

Commit 55c8a25

Browse files
committed
Ajuste de performance
1 parent 2277973 commit 55c8a25

File tree

2 files changed

+45
-24
lines changed

2 files changed

+45
-24
lines changed

config.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,23 @@
140140
# Type Refresh page
141141
# Options: 'ctrl+f5'
142142
# 'shift+f5'
143-
# 'ctrl+shift+r'
144143
# 'Todos'
145144
# [pt_BR]
146145
# Tipo de Atualização da pagina
147146
# Opçõces: 'ctrl+f5'
148147
# 'shift+f5'
149-
# 'ctrl+shift+r'
150148
# 'Todos'
151-
type_refresh: 'shift+f5'
149+
type_refresh: 'Todos'
150+
151+
# [en_US]
152+
# Mouse Speed
153+
# Default value: 0.1
154+
#
155+
# [pt_BR]
156+
# Velocidade do Mouse
157+
# Valor padrão: 0.1
158+
#
159+
mouse_speed: 0.1
152160

153161
# ============================================================ #
154162
# [en_US] End - Edit this area according to your account configuration

index.py

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ def addRandomness(n, randomn_factor_size=None):
7272
def moveToWithRandomness(x,y,t):
7373
pyautogui.moveTo(addRandomness(x,10),addRandomness(y,10),t+random()/2)
7474

75-
7675
def remove_suffix(input_string, suffix):
7776
if suffix and input_string.endswith(suffix):
7877
return input_string[:-len(suffix)]
@@ -89,7 +88,6 @@ def load_images():
8988

9089
images = load_images()
9190

92-
9391
def clickBtn(img,name=None, timeout=3, threshold = ct['default']):
9492
logger(None, progress_indicator=True)
9593
if not name is None:
@@ -111,7 +109,7 @@ def clickBtn(img,name=None, timeout=3, threshold = ct['default']):
111109
pos_click_x = x+w/2
112110
pos_click_y = y+h/2
113111

114-
moveToWithRandomness(pos_click_x,pos_click_y,1)
112+
moveToWithRandomness(pos_click_x,pos_click_y,ct['mouse_speed'])
115113
pyautogui.click()
116114

117115
return True
@@ -149,7 +147,7 @@ def scroll(clickAndDragAmount):
149147
return
150148
x,y,w,h = flagScroll[len(flagScroll)-1]
151149

152-
moveToWithRandomness(x,y,1)
150+
moveToWithRandomness(x,y,ct['mouse_speed'])
153151

154152
pyautogui.dragRel(0,clickAndDragAmount,duration=1, button='left')
155153

@@ -167,8 +165,6 @@ def refreshPage():
167165
pyautogui.hotkey('ctrl','f5')
168166
time.sleep(1.5)
169167
pyautogui.hotkey('shift','f5')
170-
time.sleep(1.5)
171-
pyautogui.hotkey('ctrl','shift','r')
172168

173169
time.sleep(ct['timeW_after_refreshPage'])
174170
processLogin()
@@ -237,7 +233,7 @@ def removeSpaceships():
237233
# pyautogui.click()
238234

239235
for (x, y, w, h) in reversed(buttons):
240-
moveToWithRandomness(x+(w/2),y+(h/2),1)
236+
moveToWithRandomness(x+(w/2),y+(h/2),ct['mouse_speed'])
241237
pyautogui.click()
242238

243239
if len(buttons) == 0:
@@ -264,7 +260,7 @@ def clickButtonsFight():
264260

265261

266262
for (x, y, w, h) in reversed(buttons): #Adjust for click button a little more intelligent
267-
moveToWithRandomness(x+ajustX+(w/2),y+ajustY+(h/2),1)
263+
moveToWithRandomness(x+ajustX+(w/2),y+ajustY+(h/2),ct['mouse_speed'])
268264
pyautogui.click()
269265
global hero_clicks
270266
hero_clicks = hero_clicks + 1
@@ -363,7 +359,6 @@ def refreshSpaceships(qtd):
363359

364360
refreshSpaceships(hero_clicks)
365361

366-
367362
def goToFight():
368363
clickBtn(images['spg-go-to-boss'])
369364
time.sleep(1)
@@ -397,7 +392,6 @@ def endFight():
397392
else:
398393
refreshPage()
399394

400-
401395
def returnBase():
402396
goToSpaceShips()
403397

@@ -475,6 +469,25 @@ def CheckTimeRestartGame():
475469

476470
return False
477471

472+
def connectWallet():
473+
if clickBtn(images['spg-connect-wallet'], name='conectBtn', timeout=5):
474+
return True
475+
476+
def checkHome():
477+
if len(positions(images['spg-go-to-boss'], threshold=ct['base_position'])) > 0:
478+
return True
479+
480+
def clickConfirm():
481+
if clickBtn(images['spg-confirm'], name='okBtn', timeout=3):
482+
return True
483+
484+
def checkProcessing():
485+
if len(positions(images['spg-processing'], threshold=ct['commom_position'])) > 0:
486+
time.sleep(ct['check_processing_time'])
487+
if len(positions(images['spg-processing'], threshold=ct['commom_position'])) > 0:
488+
return True
489+
490+
478491
def main():
479492
time.sleep(5)
480493
t = c['time_intervals']
@@ -493,28 +506,28 @@ def main():
493506

494507
now = time.time()
495508

496-
if clickBtn(images['spg-connect-wallet'], name='conectBtn', timeout=5):
509+
if (connectWallet()):
510+
bot_working = True
497511
processLogin()
498512
else:
499-
if len(positions(images['spg-go-to-boss'], threshold=ct['base_position'])) > 0:
513+
if (checkHome()):
514+
bot_working = True
500515
removeSpaceships()
501516
refreshSpaceships(0)
502-
bot_working = True
503517

504-
if clickBtn(images['spg-confirm'], name='okBtn', timeout=3):
518+
if (clickConfirm()):
519+
bot_working = True
505520
time.sleep(2)
506521
endFight()
522+
523+
if (checkVictory()):
507524
bot_working = True
508525

509-
if(checkVictory()):
526+
if (checkProcessing()):
510527
bot_working = True
511-
512-
if len(positions(images['spg-processing'], threshold=ct['commom_position'])) > 0:
513-
time.sleep(ct['check_processing_time'])
514-
if len(positions(images['spg-processing'], threshold=ct['commom_position'])) > 0:
515-
refreshPage()
528+
refreshPage()
516529

517-
if(checkClose()):
530+
if (checkClose()):
518531
bot_working = True
519532

520533
if len(positions(images['spg-surrender'], threshold=ct['end_boss']) ) > 0:

0 commit comments

Comments
 (0)