forked from aparoski/WhiteoutSurvivalBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMap_Interact.py
More file actions
230 lines (131 loc) · 5.8 KB
/
Map_Interact.py
File metadata and controls
230 lines (131 loc) · 5.8 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import pyautogui as p
import time
p.useImageNotFoundException()
import os
os.chdir(r"A:\Data_Science\Projects\Whiteout_Survival\WoS Bot")
import relative_locations as rl
import Reader
import Helper_Funcs as HF
import Image_Rec
def map_search(x1, y1, W, L) -> None:
"""pull up the search pane in the world map"""
Image_Rec.Navigate_to_cityormap(x1, y1, W, L, "World Map")
p.moveTo(x1 + W * rl.WorldMap_Search[0],
y1 + L * rl.WorldMap_Search[1])
p.click()
time.sleep(2)
def map_search_level_selection(x1, y1, W, L, level) -> None:
"""from within the search pane of world map. After the
desired category has been selected. picks out the desired level
for that category and starts search"""
p.moveTo(x1 + W * rl.WorldMap_Search_Level_Selection[0],
y1 + L * rl.WorldMap_Search_Level_Selection[1])
p.click()
time.sleep(1)
p.hotkey('ctrl', 'a')
p.press('backspace')
time.sleep(0.5)
p.write(str(level))
p.press("enter")
time.sleep(0.5)
p.moveTo(x1 + W * rl.WorldMap_Search_Button[0],
y1 + L * rl.WorldMap_Search_Button[1])
p.click()
time.sleep(2)
#rally functions----------------------------------------------
def rally_attack_button_findnpress(x1, y1, W, L, type = "Rally") -> None:
dir = "A:\\Data_Science\\Projects\\Whiteout_Survival\\WoS Bot\\images\\"
rally_file = "images_worldmap\\Terror_Rally_Button.JPG"
hold_a_rally_file = "images_worldmap\\hold_a_Rally.JPG"
attack_file = "images_worldmap\\Beast_Attack_Button.JPG"
if type == "Rally":
button_loc = HF.check_image(x1, y1, W, L,
dir + rally_file,
message = " rally button ")
p.moveTo(button_loc)
p.click()
time.sleep(1)
hold_a_rally_button_loc = HF.check_image(x1, y1, W, L,
dir + hold_a_rally_file,
message = " hold a rally button ")
p.moveTo(hold_a_rally_button_loc)
p.click()
else:
button_loc = HF.check_image(x1, y1, W, L,
dir + attack_file,
message = " attack button ")
p.moveTo(button_loc)
p.click()
def check_rally_arrival(x1, y1, W, L):
dir = "A:\\Data_Science\\Projects\\Whiteout_Survival\\WoS Bot\\images\\"
my_rally = "images_worldmap\\my_Rally.JPG"
try:
loc = HF.check_image(x1, y1, W, L, dir + my_rally, itterator = 2,
confidence = 0.7,
message = " checking if rally Icon is present ")
return(False)
except:
return(True)
def polar_sender(x1, y1, W, L, level):
"""sends out march to a polar rally"""
map_search(x1, y1, W, L)
#swipe function uses 0.5 as base so it must be subtracted from any value
#that is above 0.5...yes its ugly I know
HF.swipe(x1, y1, W, L, "left",
starting_y = rl.WorldMap_Search_Slider[1])
dir = "A:\\Data_Science\\Projects\\Whiteout_Survival\\WoS Bot\\images\\"
terror_file = "images_worldmap\\search_polar_terror.JPG"
#delay is necessary before searching for image
#after swipe slider bounces moving the icon about
time.sleep(0.5)
teror_loc = HF.check_image(x1, y1, W, L,
dir + terror_file,
message = " Polar Terror ")
p.click(teror_loc)
map_search_level_selection(x1, y1, W, L, level)
time.sleep(1)
rally_attack_button_findnpress(x1, y1, W, L, "Rally")
walk_time = Image_Rec.Preset_March_Sender(x1, y1, W, L, 1)
return(walk_time)
def Reaper_Sender(x1, y1, W, L):
Image_Rec.Hero_Mission(x1, y1, W, L)
dir = "A:\\Data_Science\\Projects\\Whiteout_Survival\\WoS Bot\\images\\images_Events\\"
reaper_map_icon = "reaper_map.JPG"
reaper_map = HF.check_image(x1, y1, W, L, dir + reaper_map_icon, message = " reaper on map ")
p.click(reaper_map)
rally_attack_button_findnpress(x1, y1, W, L, "Rally")
walk_time = Image_Rec.Preset_March_Sender(x1, y1, W, L, 1)
return(walk_time)
# def Polar_Depature_check(x1, y1, W, L, windows):
# """determines when a polar rally has departed the city"""
# time.sleep(60)
# error_int = 0
# rally_ready = check_rally_arrival(x1, y1, W, L)
# while rally_ready == "False" and error_int < 2000:
# if error_int % 10 == 0:
# print("rally wait " + str(error_int))
# time.sleep(5)
# error_int += 1
# rally_ready = check_rally_arrival(x1, y1, W, L)
#rally functions----------------------------------------------
#Beast Functions ---------------------------------------------
def Beast_Search(x1, y1, W, L, level):
map_search(x1, y1, W, L)
#swipe function uses 0.5 as base so it must be subtracted from any value
#that is above 0.5...yes its ugly I know
HF.swipe(x1, y1, W, L, "left",starting_y = rl.WorldMap_Search_Slider[1])
dir = "A:\\Data_Science\\Projects\\Whiteout_Survival\\WoS Bot\\images\\"
Beast_file = "images_worldmap\\search_beast.JPG"
#delay is necessary before searching for image
#after swipe slider bounces moving the icon about
time.sleep(0.5)
beast_loc = HF.check_image(x1, y1, W, L,
dir + Beast_file,
message = " Beast ")
p.click(beast_loc)
map_search_level_selection(x1, y1, W, L, level)
time.sleep(1)
rally_attack_button_findnpress(x1, y1, W, L, "Attack")
walk_time = Image_Rec.Preset_March_Sender(x1, y1, W, L, 1)
return(walk_time)
#Beast Functions ---------------------------------------------