This repository was archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask.py
More file actions
379 lines (362 loc) · 16.1 KB
/
task.py
File metadata and controls
379 lines (362 loc) · 16.1 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# -*- codeing = utf-8 -*-
# @Time : 2021/10/10 22:23
# @Author : 罗任姆/LoMu
# @File : task.py
# @Software : PyCharm
import numpy
import aircv as ac
import pyautogui
from windowRect import windowRect
from PIL import ImageGrab
import time
from config import *
def renWumenu():
print("任务菜单")
rect = windowRect(hWnd)
pyautogui.press("home")
x1_pos, y1_pos, x2_pos, y2_pos = rect
img_array_renwu = numpy.array(ImageGrab.grab(bbox=rect))
ipt = ac.find_template(img_array_renwu,renwu_press_img)
if ipt !=None:
renWu = (63 + x1_pos, 174 + y1_pos)
img_array = numpy.array(numpy.array(ImageGrab.grab(bbox=rect)))
renWu_bool = bool(ac.find_template(img_array,renWumenu_img,0.3))
time.sleep(0.1)
pyautogui.moveTo(renWu)
time.sleep(0.3)
pyautogui.leftClick()
time.sleep(0.3)
if renWu_bool is True:
pyautogui.moveTo(renWu[0],renWu[1]+80)
pyautogui.leftClick()
time.sleep(0.3)
img_renWuarray = numpy.array(ImageGrab.grab(bbox=rect))
renWu_Caidan_panduan_bool = bool(ac.find_template(img_renWuarray,renwu_menu_panduan_img,0.7))
if renWu_Caidan_panduan_bool == False and renWu_bool == True:
renWulingqu()
else:
rect = windowRect(hWnd)
x1_pos, y1_pos, x2_pos, y2_pos = rect
gonggao_pos = (1492 + x1_pos, 130 + y1_pos)
img_array = numpy.array(ImageGrab.grab(bbox=rect))
gongGao_ipt = ac.find_template(renWumenu_img, img_array)
if gongGao_ipt != None:
pyautogui.moveTo(gonggao_pos)
time.sleep(0.2)
pyautogui.leftClick()
time.sleep(0.9)
pyautogui.leftClick()
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(game_over_press_img)) != None:
pyautogui.keyDown('~')
pyautogui.keyUp('~')
renWumenu()
else:
rect = windowRect(hWnd)
x1_pos, y1_pos, x2_pos, y2_pos = rect
gonggao_pos = (1492 + x1_pos, 130 + y1_pos)
img_array = numpy.array(ImageGrab.grab(bbox=rect))
gongGao_ipt = ac.find_template(renWumenu_img, img_array)
if gongGao_ipt != None:
pyautogui.moveTo(gonggao_pos)
time.sleep(0.2)
pyautogui.leftClick()
time.sleep(0.9)
pyautogui.leftClick()
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(game_over_press_img)) != None:
pyautogui.keyDown('~')
pyautogui.keyUp('~')
renWumenu()
def renWulingqu():
time.sleep(2)
while True:
img_array_left =numpy.array(ImageGrab.grab(bbox=(316+x1_pos, 143+y1_pos, 909+x1_pos, 306+y1_pos)))
# 316, 143, 909, 306
renWu_lingqu_bool_left = (ac.find_template( img_array_left,renwu_lingqu_img,0.8))
img_array_right =numpy.array(ImageGrab.grab(bbox=((20+316+x1_pos)*2, 143+y1_pos, (x2_pos-50), 306+y1_pos)))
renWu_lingqu_bool_right = ac.find_template(img_array_right,renwu_lingqu_img,0.8)
task_150 = ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),numpy.array(task_150_img),1)
task_165 = ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),numpy.array(task_165_img),1)
if renWu_lingqu_bool_left != None:
print()
print("任务奖励已领取")
pyautogui.moveTo(812+x1_pos, 263+y1_pos)
pyautogui.leftClick()
time.sleep(0.3)
pyautogui.moveTo(801+x1_pos, 704+y1_pos)
pyautogui.leftClick()
time.sleep(1)
elif renWu_lingqu_bool_right != None:
print()
print("任务奖励已领取")
pyautogui.moveTo(1441+x1_pos,257+y1_pos)
pyautogui.leftClick()
time.sleep(0.3)
pyautogui.moveTo(801+x1_pos, 704+y1_pos)
pyautogui.leftClick()
time.sleep(1)
elif task_150 !=None or task_165 !=None :
print("使命领取")
#649, 776 860, 776 1078, 776 1286, 776 1509, 776
pyautogui.moveTo(649+x1_pos,776+y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(795+x1_pos, 708+y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(860 + x1_pos, 776 + y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(795+x1_pos, 708+y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(1078 + x1_pos, 776 + y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(795+x1_pos, 708+y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(1286 + x1_pos, 776 + y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(795+x1_pos, 708+y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(1509 + x1_pos, 776 + y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(795+x1_pos, 708+y1_pos)
pyautogui.leftClick()
print("当前所有任务已完成 -程序结束")
break
else:
renWustart()
break
def renWustart():
print()
print("开始每日任务")
window_img_array = numpy.array(ImageGrab.grab(bbox=rect))
yaoristart = ac.find_template(window_img_array, numpy.array(renwu_yaori_start_img), 0.8)
task_Master_Start = ac.find_template(window_img_array, numpy.array(task_master_img), 0.8)
game_Coins_Start = ac.find_template(window_img_array,numpy.array(task_game_coins_img),0.8)
task_team_Start = ac.find_template(window_img_array,numpy.array(task_team_img),0.8)
if game_Coins_Start != None:
print("家园福利")
game_coins_start(game_Coins_Start['result'])
elif yaoristart != None:
print("材料活动")
yaoRi_start(yaoristart['result'])
elif task_Master_Start != None:
print("[光与影的彼岸-第十二章]")
task_master_start(task_Master_Start['result'])
elif task_team_Start != None:
print("舰团委托")
task_team_start(task_team_Start['result'])
else:
print("任务结束")
#elif task 舰团委托
def task_team_start(task_team_Start_pos):
x, y = task_accept_pos(task_team_Start_pos)
pyautogui.moveTo(x, y)
pyautogui.leftClick()
time.sleep(0.09)
task_team_submit_pos=ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),
numpy.array(task_team_submit_img), 0.7)
task_team_submit_ets_pos = ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),
numpy.array(task_team_submit_ets_img), 0.7)
break1=True
sum = 0
while break1:
if sum == 2:
break1 = False
if task_team_submit_pos != None:
x,y= task_team_submit_pos['result']
pyautogui.moveTo(xY_pos(x,y))
time.sleep(0.5)
pyautogui.leftClick()
if task_team_submit_ets_pos !=None:
x, y = task_team_submit_ets_pos['result']
pyautogui.moveTo(xY_pos(x, y))
time.sleep(0.5)
pyautogui.leftClick()
sum +=1
else:
pyautogui.moveTo(xY_pos(219, 833))
time.sleep(0.5)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(xY_pos(1399, 349))
time.sleep(0.5)
pyautogui.leftClick()
def task_master_twelve():
task_pos = ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),
numpy.array(task_master_twelve_img), 0.7)
print("[光与影的彼岸-第十二章] 开始")
pyautogui.moveTo(task_pos['result'] + (x1_pos, y1_pos))
pyautogui.leftClick()
def task_master_twelve_12_14():
pyautogui.moveTo(850 + x1_pos, 481 + y1_pos)
time.sleep(2)
pyautogui.leftClick()
sum = 0
break1 =True
print("后续将以相对坐标进行处理,请勿操作")
print("默认进行10次")
while break1:
break2 = True
if sum == task_master_12_14_sum:
break1 = False
renWumenu()
elif ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(task_master_twelve_12_14_img),0.8) != None:
pyautogui.moveTo(ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(task_master_twelve_12_14_img),
0.7)['result']+(x1_pos,y1_pos))
time.sleep(0.5)
pyautogui.leftClick()
time.sleep(0.3)
pyautogui.press('i')
time.sleep(0.3)
pyautogui.press('i')
time.sleep(0.5)
while break2:
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(quchutili_img),0.6) != None:
time.sleep(0.5)
pyautogui.moveTo(938+x1_pos, 727+y1_pos)
time.sleep(1)
pyautogui.leftClick()
pyautogui.leftClick()
time.sleep(0.5)
print("取出体力")
pyautogui.press('i')
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(game_loading_img)) == None:
break2 = False
break3 = True
break_t2 = True
break_t3 = True
time.sleep(3)
pyautogui.moveTo(1491 + x1_pos, 71 + y1_pos)
pyautogui.leftClick()
time.sleep(0.1)
pyautogui.leftClick()
while break3:
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(task_12_14_tiaoguo_img)) != None:
pyautogui.moveTo(1021 + x1_pos, 659 + y1_pos)
time.sleep(0.5)
pyautogui.leftClick()
pyautogui.leftClick()
time.sleep(0.2)
pyautogui.moveTo(1491 + x1_pos, 71 + y1_pos)
time.sleep(1.3)
pyautogui.leftClick()
time.sleep(0.3)
print("跳过1")
break3 =False
while break_t2:
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),
numpy.array(task_12_14_tiaoguo_img)) != None:
break_t2 = False
pyautogui.press('i')
print("跳过2")
pyautogui.moveTo(1491 + x1_pos, 71 + y1_pos)
time.sleep(1.3)
pyautogui.leftClick()
time.sleep(0.5)
while break_t3:
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),
numpy.array(task_12_14_tiaoguo_img)) != None:
break_t3 = False
pyautogui.press('i')
print("跳过3")
time.sleep(8)
pyautogui.leftClick()
time.sleep(3)
print("已完成[光与影的彼岸-第十二章] 12-14 ")
else:
pyautogui.moveTo(1491 + x1_pos, 71 + y1_pos)
time.sleep(0.5)
pyautogui.leftClick()
else:
pyautogui.moveTo(1491 + x1_pos, 71 + y1_pos)
time.sleep(0.5)
pyautogui.leftClick()
else:
pyautogui.moveTo(1491 + x1_pos, 71 + y1_pos)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.leftClick()
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(task_12_14_Act4_img)) != None:
pyautogui.moveTo(ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(task_12_14_over_img))['result']+(x1_pos,y1_pos))
pyautogui.keyDown("i")
pyautogui.keyUp("i")
sum+=1
print(f"当前关卡次数{sum}")
if sum == 0:
pyautogui.keyDown('right')
pyautogui.keyUp('right')
time.sleep(1)
def task_master_start(task_Master_Start):
x,y = task_accept_pos(task_Master_Start)
pyautogui.moveTo(x,y)
pyautogui.leftClick()
time.sleep(0.09)
pyautogui.moveTo(850 + x1_pos, 481 + y1_pos)
break1 = True
while break1:
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),numpy.array(task_master_one_img),0.7) == None:
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(task_master_twelve_img),0.7) != None:
task_master_twelve()
task_master_twelve_12_14()
break1 = False
else:
print("正在向左寻找 [光与影的彼岸-第十二章] ")
pyautogui.scroll(-10)
else:
while break1:
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)), numpy.array(task_master_twelve_img),0.7) != None:
task_master_twelve()
task_master_twelve_12_14()
break1 = False
else:
print("正在向右寻找 [光与影的彼岸-第十二章]")
pyautogui.scroll(10)
task_progress['task_master'] = 1
def game_coins_start(game_conins_pos):
x,y=task_accept_pos(game_conins_pos)
pyautogui.moveTo(x,y)
pyautogui.leftClick()
time.sleep(0.09)
if ac.find_template(numpy.array(ImageGrab.grab(bbox=rect)),numpy.array(task_home_walfare_img),0.3) != None:
time.sleep(1)
pyautogui.moveTo(450+x1_pos, 201+y1_pos) #体力 x - 200
time.sleep(0.5)
print("调用易键鼠点击")
objdll.M_LeftClick(hdl, 1)
time.sleep(1)
pyautogui.moveTo(250 + x1_pos, 201 + y1_pos)
time.sleep(0.5)
objdll.M_LeftClick(hdl, 1)
time.sleep(0.5)
pyautogui.moveTo(938 + x1_pos, 727 + y1_pos)
objdll.M_LeftClick(hdl, 1)
task_progress['game_coins'] = 1
pyautogui.keyDown('`')
pyautogui.keyUp('`')
renWumenu()
else:
pyautogui.keyDown('`')
pyautogui.keyUp('`')
renWumenu()
def yaoRi_start(pos):
x, y = task_accept_pos(pos)
pyautogui.moveTo(x, y)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(xY_pos(1528, 855))
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.moveTo(xY_pos(801, 686))
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.leftClick()
time.sleep(0.5)
pyautogui.press('home')
task_progress['yaori'] = 1
renWumenu()