Skip to content

Commit

Permalink
Fixed an issue where settings wouldn't get clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
skasero committed Feb 16, 2021
1 parent b902d61 commit eb13480
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def runner(self, iterations = 3):
gameStartImage = self.imagePath + 'start.png'
playAgainImage = self.imagePath + 'play_again.png'
cancelQueueImage = self.imagePath + 'cancel_queue.png'
location = [] # empty array
surrenderP1Image = self.imagePath + 'surrender_p1.png'

for i in range(iterations):
print(f'Iteration: {i+1} / {iterations}')
Expand All @@ -68,6 +68,7 @@ def runner(self, iterations = 3):
gameStarted = False

for image in full_imageArray:
location = [-1,-1] ## null array
imageFile = self.imagePath + image
time.sleep(0.5)
if(image == 'accept.png'):
Expand Down Expand Up @@ -135,10 +136,16 @@ def runner(self, iterations = 3):
else:
raise Exception("This should never be reached and something wrong has happened")

try:
self.clickImage(location[0],location[1])
except:
pass
self.clickImage(location[0],location[1])

## This is a special case where sometimes settings isn't clicked on
if(image == 'settings.png'):
surrenderLocation = self.findImage(surrenderP1Image,self.ingame_scale)
while(surrenderLocation[0] == -1):
location = self.findImage(imageFile,self.ingame_scale)
self.clickImage(location[0],location[1])
time.sleep(1)
surrenderLocation = self.findImage(surrenderP1Image,self.ingame_scale)

## This means that it didn't find a game before the last iteration
if(attempt == 2 and gameStarted == False):
Expand Down

0 comments on commit eb13480

Please sign in to comment.