-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
124 lines (101 loc) · 4.27 KB
/
run.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
'''
This file will take care of every scenario case or a run.
Lose, Win, refills are some of them.
'''
import time
import bot
#Used when victory and defeat screen appear.
longWaitTime = 1.9
mediumWaitTime = 1.1
#Used when we don't need to wait too long before clicking
shortWaitTime = 0.6
'''
This procedure will be called when the player has failed a run.
The program will then refuse to revive himself for 10 crystals and
start a new run.
'''
def playerDied():
bot.clickImage('noBtn.png', longWaitTime)
bot.clickImage('loseScreen.png', shortWaitTime)
bot.clickImage('prepareBtn.png', shortWaitTime)
'''
This procedure will be called when the player has finished a run.
It will click on the victory screen, open the chest and get or sell the items.
'''
def victoryScreen():
bot.clickImage('rewardScreen.png', 0.1)
bot.clickImage('chest.png', mediumWaitTime)
if(bot.imageIsFound('okBtn.png')):
bot.clickImage('okBtn.png', shortWaitTime)
else:
if(bot.imageIsFound('6starsRune.png') or bot.imageIsFound('legendRune.png')):
bot.clickImage('getRuneBtn.png', shortWaitTime)
elif(bot.imageIsFound('5starsRune.png')):
bot.clickImage('sell.png', shortWaitTime)
bot.clickImage('yesBtn.png', shortWaitTime)
bot.clickImage('replay.png', shortWaitTime)
def refillWithCrystals():
bot.clickImage('shopBtn.png', shortWaitTime)
bot.clickImage('refillCrystals.png', shortWaitTime)
bot.clickImage('yesRefillBtn.png', mediumWaitTime)
bot.clickImage('okBtn.png', shortWaitTime)
bot.clickImage('closeShop.png', shortWaitTime)
def noMoreEnergy():
return bot.imageIsFound('notEnoughEnergy.png')
def startRun():
runIsDone = False
while(runIsDone == False):
try:
if(bot.imageIsFound('replay.png')):
bot.clickImage('replay.png', shortWaitTime)
elif(bot.imageIsFound('okBtn.png')):
bot.clickImage('okBtn.png', shortWaitTime)
elif(bot.imageIsFound('5starsRune.png')):
bot.clickImage('sell.png', shortWaitTime)
bot.clickImage('yesBtn.png', shortWaitTime)
elif(bot.imageIsFound('prepareBtn.png')):
bot.clickImage('prepareBtn.png', shortWaitTime)
elif(bot.imageIsFound('startBattleBtn.png')):
bot.clickImage('startBattleBtn.png', shortWaitTime)
elif(bot.imageIsFound('notEnoughEnergy.png')):
runIsDone = True
elif(bot.imageIsFound('rewardScreen.png')):
time.sleep(0)
victoryScreen()
elif(bot.imageIsFound('reviveBtn.png')):
time.sleep(longWaitTime)
playerDied()
except:
print("Exception raised.")
def faimonRun():
while(noMoreEnergy()==False):
try:
if(bot.imageIsFound('replay.png')):
bot.clickImage('replay.png', shortWaitTime)
elif(bot.imageIsFound('okBtn.png')):
bot.clickImage('okBtn.png', 0)
elif(bot.imageIsFound('sell.png')):
bot.clickImage('sell.png', 0)
if(bot.imageIsFound('yesBtn.png')):
bot.clickImage('yesBtn.png', shortWaitTime)
elif(bot.imageIsFound('rewardScreen.png')):
bot.clickImage('rewardScreen.png', shortWaitTime)
bot.clickImage('chest.png', shortWaitTime)
except:
print("catch")
def toaRun():
while(noMoreEnergy()==False):
try:
if(bot.imageIsFound('startBattleBtn.png')):
bot.clickImage('startBattleBtn.png', shortWaitTime)
elif(bot.imageIsFound('okBtn.png')):
bot.clickImage('okBtn.png', 0)
elif(bot.imageIsFound('yesBtn.png')):
bot.clickImage('yesBtn.png', shortWaitTime)
elif(bot.imageIsFound('rewardScreen.png')):
bot.clickImage('rewardScreen.png', shortWaitTime)
bot.clickImage('chest.png', shortWaitTime)
elif(bot.imageIsFound('nextStage.png')):
bot.clickImage('nextStage.png', shortWaitTime)
except:
print("catch")