-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
147 lines (107 loc) · 4.39 KB
/
main.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
from time import sleep as wait
import os
import keyboard
import pyautogui
# move mouse to the top left of the screen to trigger
pyautogui.FAILSAFE = True
# image folder path
images_folder = os.path.join(os.path.dirname(os.path.abspath(__file__)), "images")
# what items to buy
buy_covenants = True
buy_mystics = True
# item buy button x & y offset
# adjust this to the click the buy button to the right of the item
button_add_x = 800 # higher value = further right
button_add_y = 20 # higher value = further down
# start delay
start_timer = 5
# count var
c = 0
m = 0
# flags
scrolled = False
bought_c = False
bought_m = False
print(f"Running in {start_timer}...")
wait(start_timer)
# hold down q to end
while not keyboard.is_pressed('q') or not (buy_covenants and buy_mystics):
in_shop = pyautogui.locateCenterOnScreen(os.path.join(images_folder, "shop.png"), confidence=.90)
if in_shop:
# mystic bookmarks
mystic = pyautogui.locateCenterOnScreen(os.path.join(images_folder, "mystic_icon.png"), confidence=.90)
# covenant bookmarks
covenant = pyautogui.locateCenterOnScreen(os.path.join(images_folder, "covenant_icon.png"), confidence=.90)
# refresh button
refresh_button = pyautogui.locateCenterOnScreen(os.path.join(images_folder, "refresh_button.png"),
confidence=.90)
if mystic and not bought_m and buy_mystics:
wait(0.5)
# print("Mystics Found --> Buying")
# click the buy button to the right of the item
mystic_buy_button_x, mystic_buy_button_y = mystic
pyautogui.click(int(mystic_buy_button_x) + button_add_x, int(mystic_buy_button_y) + button_add_y,
button='left')
wait(0.5)
# find and click the confirm button
mystic_confirm_buy_button = pyautogui.locateCenterOnScreen(os.path.join(images_folder, "mystic_buy_button"
".png"),
confidence=.80)
pyautogui.click(mystic_confirm_buy_button, button='left')
# wait for the animation to play
wait(3)
# count
bought_m = True
m += 1
if covenant and not bought_c and buy_covenants:
wait(0.5)
# print("Covenants Found --> Buying")
# click the buy button to the right of the item
covenant_buy_button_x, covenant_buy_button_y = covenant
pyautogui.click(int(covenant_buy_button_x) + button_add_x, int(covenant_buy_button_y) + button_add_y,
button='left')
wait(0.5)
# find and click the confirm button
covenant_confirm_buy_button = pyautogui.locateCenterOnScreen(
os.path.join(images_folder, "covenant_buy_button.png"),
confidence=.80)
pyautogui.click(covenant_confirm_buy_button, button='left', clicks=2)
# wait for the animation to play
wait(3)
bought_c = True
# count
c += 1
# scroll
if not scrolled:
# scroll down
pyautogui.scroll(-5000)
# wait for animation to end
wait(1)
# reset flag
scrolled = True
# search again after scroll
continue
# refresh
print("Refreshing...")
# click refresh button
wait(0.5)
pyautogui.click(refresh_button, button='left', clicks=2)
wait(1)
# find and click refresh confirm button
refresh_button_confirm = pyautogui.locateCenterOnScreen(
os.path.join(images_folder, "confirm_refresh_button.png"),
confidence=.90)
pyautogui.click(refresh_button_confirm, button='left')
wait(1)
# reset flags
scrolled = False
bought_m = False
bought_c = False
# break if not in shop
else:
print("NOT IN SHOP")
break
# print when loop ends
if c > 0 or m > 0:
print(f"Covenants found {c * 5}\nMystics found {m * 50}")
input("Press Enter to continue...")