yys_task.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708
  1. # -*- coding: utf-8 -*-
  2. from scriptBase.imgFind import pcacc_img, savePic
  3. from scriptBase.mouseClick import pcacc_mouse
  4. from scriptBase.ocr import capture_and_ocr
  5. import scriptBase.base
  6. from scriptBase.comon import *
  7. from scriptBase.ocr import *
  8. from apscheduler.schedulers.blocking import BlockingScheduler
  9. import pyautogui
  10. import random
  11. import sys
  12. import math
  13. import os
  14. import time
  15. from yys_define import *
  16. from yys_pic import *
  17. import subprocess
  18. from yys_pic import _imported
  19. import socket
  20. '''
  21. 基础配置说明:
  22. 1280*720(DPI 240)
  23. 游戏画面:流畅
  24. 高帧率关闭
  25. 町中模式:旧版
  26. '''
  27. def task_getComputerName():
  28. return socket.gethostname()
  29. def task_acceptTask():
  30. while True:
  31. if waitFindImg_withBool(public_img.xiezhu, 0.1, 4) == True:
  32. waitClickImg_withBool(public_img.accept, 0.4, 0.5)
  33. def init():
  34. global _imported
  35. if not _imported:
  36. acceptTask = threading.Thread(target=task_acceptTask)
  37. acceptTask.daemon = True
  38. if acceptTask.is_alive() == False:
  39. acceptTask.start()
  40. _imported = True
  41. class basic_operate:
  42. @staticmethod
  43. def find_place():
  44. if waitFindImg_withBool(place_img.search, 0.4, 0):
  45. return PLACE.SEARCH
  46. if waitFindImg_withBool(place_img.Town, 0.4, 0):
  47. return PLACE.TOWN
  48. if waitFindImg_withBool(place_img.outside, 0.4, 0):
  49. return PLACE.OUTSIDE
  50. return PLACE.NONE
  51. @staticmethod
  52. def do_back():
  53. ret = False
  54. ret |= waitClickImg_noWait_withBool(place_img.back1, 0.6, 0)
  55. ret |= waitClickImg_noWait_withBool(place_img.back2, 0.6, 0)
  56. ret |= waitClickImg_noWait_withBool(place_img.close, 0.6, 0)
  57. ret |= waitClickImg_noWait_withBool(place_img.enter, 0.6, 0)
  58. @staticmethod
  59. def do_fight(fightBeginWait = 10):
  60. if fightBeginWait > 0:
  61. if waitClickImg_withBool(public_img.fight_begin, fightBeginWait, 1) == False:
  62. return False
  63. waitClickImg_withBool(public_img.fight_begin, 2, 5)
  64. if waitClickImg_noWait_withBool([public_img.fight_fail,public_img.fight_fail2,public_img.fight_fail3,public_img.fight_success,public_img.fight_success2, public_img.miwen_success, public_img.guiwang_success],180,1) == False:
  65. return False
  66. waitClickImg_noWait_withBool([public_img.fight_fail,public_img.fight_fail2,public_img.fight_fail3,public_img.fight_success,public_img.fight_success2, public_img.miwen_success, public_img.guiwang_success],1,1)
  67. return True
  68. def task_return_game():
  69. tryTimes = 3
  70. while tryTimes > 0:
  71. if False == waitFindImg_withBool([place_img.title, place_img.title2], 1, 1):
  72. waitClickImg_noWait([place_img.ico, place_img.ico2], 1, 0)
  73. myTimeSleep_big()
  74. tryTimes -= 1
  75. if tryTimes == 0:
  76. return False
  77. else:
  78. break
  79. def task_goto_place(place : PLACE):
  80. task_return_game()
  81. cur_place = basic_operate.find_place() #当前位置
  82. dstMsg = "From " + cur_place.name + " to " + place.name
  83. if cur_place == place:
  84. if place == PLACE.TOWN and waitFindImg_withBool(zudui_img.zudui, 1, 1) == False:
  85. waitClickImg_noWait_withBool([place_img.juanzhou,place_img.juanzhou2], 1, 1)
  86. return True
  87. #try back to Town
  88. try_times = 5
  89. while try_times > 0 and PLACE.NONE == cur_place:
  90. basic_operate.do_back()
  91. cur_place = basic_operate.find_place()
  92. try_times -= 1
  93. if cur_place == PLACE.SEARCH:
  94. basic_operate.do_back()
  95. elif cur_place == PLACE.OUTSIDE:
  96. waitClickImg(place_img.outside, 1, 1)
  97. #cur in town, go to dst
  98. if waitFindImg_withBool(zudui_img.zudui, 1, 1) == False:
  99. waitClickImg_noWait_withBool([place_img.juanzhou,place_img.juanzhou2], 1, 1)
  100. if place == PLACE.SEARCH:
  101. waitClickImg(place_img.Town, 1, 1)
  102. elif place == PLACE.OUTSIDE:
  103. waitClickImg(place_img.goOutside, 1, 1)
  104. myTimeSleep_big()
  105. return place == basic_operate.find_place()
  106. def task_save_compress_pic():
  107. # 截取屏幕截图
  108. screenshot = pyautogui.screenshot()
  109. compressed_data = compress_image(screenshot)
  110. # 保存压缩后的图像到文件
  111. with open('compressed_screenshot.jpg', 'wb') as f:
  112. f.write(compressed_data)
  113. def task_close_game():
  114. task_return_game()
  115. if waitClickImg_withBool(gameStart_img.close, 5, 1):
  116. myTimeSleep(10)
  117. subprocess.call(f"taskkill /f /im MuMuPlayer.exe")
  118. subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
  119. subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
  120. myTimeSleep_big()
  121. def task_start_game():
  122. isSuccess = False
  123. path1 = R'C:\\Program Files\\Netease\\MuMuPlayer-12.0\\shell\\MuMuPlayer.exe'
  124. path2 = R'C:\Program Files\Netease\MuMu Player 12\shell\MuMuPlayer.exe'
  125. if os.path.exists(path1):
  126. subprocess.Popen(path1)
  127. elif os.path.exists(path2):
  128. subprocess.Popen(path2)
  129. if waitClickImg_withBool(gameStart_img.ico, 100, 20) == False:
  130. return False
  131. waitFindImg_withBool(gameStart_img.gameIn, 100, 10)
  132. while waitFindImg_withBool(gameStart_img.gameIn, 5, 10) == False:
  133. x1, y1 = get_yys_random_point((120, 120, 120, 120))
  134. pcacc_mouse.click(x1, y1)
  135. myTimeSleep(10)
  136. while waitFindImg_withBool(place_img.Town, 5, 5) == False:
  137. x1, y1 = get_yys_random_point(gameStart_img.enterGame)
  138. pcacc_mouse.click(x1, y1)
  139. isSuccess = True
  140. myTimeSleep_big()
  141. return isSuccess
  142. class yys_task:
  143. def __init__(self, name):
  144. self.name = name
  145. def run(self):
  146. print(f"Running task: {self.name}")
  147. def task_daoguan():
  148. waitClickImg_withBool(public_img.fight_begin, 3, 0)
  149. class task_yeyuanhuo(yys_task):
  150. def __init__(self):
  151. super().__init__(f"打业原火XXX100次")
  152. def run(self):
  153. tryTimes = 100
  154. while tryTimes > 0:
  155. tryTimes -= 1
  156. waitClickImg_withBool([public_img.tiaozhan,public_img.tiaozhan2,public_img.tiaozhan3,public_img.tiaozhan4, public_img.tiaozhan5, public_img.tiaozhan6, public_img.tiaozhan7, public_img.tiaozhan8, public_img.tiaozhan8,public_img.guiwang
  157. , public_img.guiwangFight], 10, 0)
  158. basic_operate.do_fight()
  159. class task_zhaohuan(yys_task):
  160. def __init__(self):
  161. super().__init__(f"召唤100次")
  162. def run(self):
  163. tryTimes = 100
  164. while tryTimes > 0:
  165. tryTimes = tryTimes - 1
  166. waitClickImg_withBool(special_img.zhaohuan, 1, 3)
  167. class task_chaoguiwang(yys_task):
  168. def __init__(self):
  169. super().__init__(f"打超鬼王4次")
  170. def run(self):
  171. tryTimes = 4
  172. while tryTimes > 0:
  173. '''
  174. if True == waitClickImg_noWait_withBool(chaoguiwang_img.xiaohao, 2, 0):
  175. myTimeSleep_big()
  176. waitClickImg_withBool(public_img.guiwang, 10, 0)
  177. myTimeSleep_big()
  178. waitClickImg_noWait(chaoguiwang_img.jijie, 3, 0)
  179. myTimeSleep_big()
  180. waitClickImg_noWait(chaoguiwang_img.kongbai, 2, 0)
  181. myTimeSleep_big()
  182. waitClickImg_noWait(zudui_img.invite, 5, 1)
  183. myTimeSleep_big()
  184. waitClickImg_noWait(chaoguiwang_img.main, 10, 0)
  185. myTimeSleep(60)
  186. '''
  187. task_goto_place(PLACE.TOWN)
  188. myTimeSleep_big()
  189. waitClickImg(chaoguiwang_img.first, 2, 0)
  190. myTimeSleep_big()
  191. waitClickImg(chaoguiwang_img.second, 2, 0)
  192. myTimeSleep_big()
  193. #waitClickImg(chaoguiwang_img.monster, 2, 0)
  194. #myTimeSleep_big()
  195. waitClickImg(public_img.guiwang, 2, 0)
  196. myTimeSleep_big()
  197. curTime = 3
  198. while curTime > 0:
  199. curTime = curTime - 1
  200. waitClickImg_noWait(chaoguiwang_img.normal, 1, 1)
  201. if False == waitClickImg_withBool(public_img.guiwangFight, 10, 0):
  202. break
  203. basic_operate.do_fight()
  204. myTimeSleep(20)
  205. tryTimes = tryTimes - 1
  206. return True
  207. class task_xiaohaochaoguiwang(yys_task):
  208. def __init__(self):
  209. super().__init__(f"小号打超鬼王10次")
  210. def run(self):
  211. while True:
  212. myTimeSleep_big()
  213. waitClickImg(chaoguiwang_img.xiaohao, 2, 0)
  214. myTimeSleep_big()
  215. waitClickImg_withBool(public_img.guiwang, 10, 0)
  216. myTimeSleep_big()
  217. waitClickImg_noWait(chaoguiwang_img.jijie, 3, 0)
  218. myTimeSleep_big()
  219. waitClickImg_noWait(chaoguiwang_img.kongbai, 2, 0)
  220. myTimeSleep_big()
  221. waitClickImg_noWait(zudui_img.invite, 5, 1)
  222. myTimeSleep(60)
  223. waitClickImg_noWait(chaoguiwang_img.main, 10, 0)
  224. task_goto_place(PLACE.TOWN)
  225. myTimeSleep_big()
  226. waitClickImg(chaoguiwang_img.first, 2, 0)
  227. myTimeSleep_big()
  228. waitClickImg(chaoguiwang_img.second, 2, 0)
  229. myTimeSleep_big()
  230. waitClickImg(chaoguiwang_img.monster, 2, 2)
  231. while True:
  232. task_goto_place(PLACE.TOWN)
  233. myTimeSleep_big()
  234. waitClickImg(chaoguiwang_img.first, 2, 0)
  235. myTimeSleep_big()
  236. waitClickImg(chaoguiwang_img.second, 2, 0)
  237. myTimeSleep_big()
  238. if False == waitClickImg(chaoguiwang_img.monster, 2, 2):
  239. break
  240. while True:
  241. if False == waitClickImg_withBool(public_img.guiwangFight, 10, 0):
  242. break
  243. basic_operate.do_fight()
  244. myTimeSleep(20)
  245. return True
  246. class task_tansuo(yys_task):
  247. def __init__(self, num, easy=False):
  248. super().__init__(f"探索第{num}章")
  249. self.num = num
  250. self.easy = easy
  251. def run(self):
  252. task_goto_place(PLACE.SEARCH)
  253. #滑动到第一章
  254. template = tansuo_img.zhangjie
  255. num_sel = template.format(self.num)
  256. if waitClickImg_withBool(num_sel,1,1) == False:#一般使最后一章,先尝试查找
  257. if waitClickImg_withBool(tansuo_img.tansuo,2,1) == False:#正常打完在再次探索页面
  258. if self.num < 20:
  259. max_tryTime = 10
  260. while max_tryTime > 0 and waitFindImg_withBool(template.format(1),0.4,1) == False:
  261. yys_dragAuto(tansuo_img.select_drag_up)
  262. max_tryTime -=1
  263. max_tryTime = 10
  264. while max_tryTime > 0 and waitClickImg_withBool(num_sel,0.4,1) == False:
  265. yys_dragAuto(tansuo_img.select_drag_down)
  266. max_tryTime -=1
  267. #随意,不影响结果
  268. if self.easy == True:
  269. waitClickImg_withBool(tansuo_img.easy,0.4,1)
  270. else:
  271. waitClickImg_withBool(tansuo_img.kunnan,0.4,1)
  272. if waitClickImg_withBool(tansuo_img.tansuo,2,1) == False:
  273. task_goto_place(PLACE.SEARCH)
  274. #滑动到第一章
  275. template = tansuo_img.zhangjie
  276. num_sel = template.format(self.num)
  277. end = [1083+(random.randint(0,30)),600+(random.randint(0,30))]
  278. start = [1077+(random.randint(0,30)),304+(random.randint(0,30))]
  279. if waitClickImg_withBool(tansuo_img.tansuo,2,1) == False:#正常打完在再次探索页面
  280. max_tryTime = 10
  281. while max_tryTime > 0 and waitFindImg_withBool(template.format(1),0.4,1) == False:
  282. yys_dragAuto(tansuo_img.select_drag_up)
  283. max_tryTime -=1
  284. max_tryTime = 10
  285. while max_tryTime > 0 and waitClickImg_withBool(num_sel,0.4,1) == False:
  286. yys_dragAuto(tansuo_img.select_drag_down)
  287. max_tryTime -=1
  288. #随意,不影响结果
  289. if self.easy == True:
  290. waitClickImg_withBool(tansuo_img.easy,0.4,1)
  291. else:
  292. waitClickImg_withBool(tansuo_img.kunnan,0.4,1)
  293. if waitClickImg_withBool(tansuo_img.tansuo,2,1) == False:
  294. return False
  295. drag_times = 30
  296. while drag_times > 0 and waitClickImg_withBool([tansuo_img.boss, tansuo_img.boss2, tansuo_img.boss3], 0.4, 0.4) == False:
  297. if waitClickImg_withBool(tansuo_img.xiaoguai, 1, 1):
  298. if waitFindImg_withBool(tansuo_img.backIco, 1, 1):
  299. drag_times = 30
  300. continue
  301. basic_operate.do_fight(0)
  302. waitFindImg(tansuo_img.backIco, 10, 1)
  303. else:
  304. yys_dragAuto(tansuo_img.tansuo_drag)
  305. drag_times-=1
  306. if drag_times == 0:
  307. print("拖动到没有小怪的地方了")
  308. return False
  309. basic_operate.do_fight(0)
  310. waitFindImg(tansuo_img.backIco, 10, 1)
  311. #寻找小纸人宝箱
  312. while waitClickImg_withBool(tansuo_img.box, 3 ,1) == True:
  313. ret,pos = waitFindImg(tansuo_img.box_get, 3, 1)
  314. if ret:
  315. pcacc_mouse.click(pos[0]+random.randint(150,300),pos[1]-random.randint(100,120))
  316. if waitFindImg_withBool(tansuo_img.box_get, 1, 1):
  317. pcacc_mouse.click(pos[0]+random.randint(150,300),pos[1]-random.randint(100,120))
  318. if waitClickImg_withBool([tansuo_img.big_box,tansuo_img.big_box2,tansuo_img.big_box3],3,0) == True:
  319. if waitClickImg_withBool(tansuo_img.big_box_get,2,1) == False:
  320. return False
  321. return True
  322. class task_pata(yys_task):
  323. def __init__(self):
  324. super().__init__("爬塔")
  325. def run(self):
  326. waitClickImg(special_img.tiaozhan, 10, 1)
  327. basic_operate.do_fight(0)
  328. class task_topo(yys_task):
  329. def __init__(self, retryTimes, person = True):
  330. if person:
  331. super().__init__("个人突破")
  332. else:
  333. super().__init__("阴阳寮突破")
  334. self.retryTimes = retryTimes
  335. self.person = person
  336. def run(self):
  337. while self.retryTimes:
  338. self.retryTimes = self.retryTimes - 1
  339. task_goto_place(PLACE.SEARCH)
  340. fail_time = 0
  341. fight_time = 0
  342. if waitClickImg_withBool(topo_img.topo,2,1) == False:
  343. return False
  344. if self.person == False:
  345. waitClickImg_withBool(topo_img.liaotopo, 2, 1)
  346. for i in range(5, -1, -1):
  347. myTimeSleep_big()
  348. star = topo_img.star
  349. sel = star.format(i)
  350. positions =list(pyautogui.locateAllOnScreen(sel, confidence=0.85))
  351. for position in positions:
  352. #pyautogui.screenshot(imageFilename='yys_tmp.png', region=position)
  353. region = (position[0] - 30,position[1]-100,280,150)
  354. #pyautogui.screenshot(imageFilename='yys2.png', region=region)
  355. myTimeSleep_big()
  356. ret = pcacc_img.find_img_in_area(topo_img.fail, region)
  357. ret2 = pcacc_img.find_img_in_area(topo_img.fail2, region)
  358. ret3 = pcacc_img.find_img_in_area(topo_img.fail3, region)
  359. print(f'find {sel}, {position}, {ret}, {ret2}, {ret3}')
  360. if pcacc_img.find_img_in_area(sel, region) == False:
  361. continue
  362. if ret == False and ret2 == False and ret3 == False:
  363. click_pos = pcacc_img.choose_one_point_from_position(position)
  364. star_tryTimes = 3
  365. #点击star位置
  366. while star_tryTimes>0 and waitFindImg_withBool(topo_img.fight,2,1) == False:
  367. pcacc_mouse.click(click_pos[0], click_pos[1])
  368. star_tryTimes-=1
  369. myTimeSleep_small()
  370. fight_tryTimes = 3
  371. while fight_tryTimes>0 and waitFindImg_withBool(topo_img.fight,2,1) == True:
  372. if waitClickImg_withBool(topo_img.fight,2,1) == False:
  373. return False
  374. fight_tryTimes-=1
  375. myTimeSleep_small()
  376. if fight_tryTimes == 0:
  377. return False
  378. basic_operate.do_fight()
  379. if waitClickImg_withBool(tansuo_img.big_box_get,2,1) == True:
  380. print("tupo宝箱获取")
  381. waitFindImg(topo_img.tupo_title, 10, 2)
  382. myTimeSleep_small()
  383. if waitFindImg_withBool(topo_img.box3, 1, 0) == True:
  384. break
  385. fight_time+=1
  386. #打满5次后刷新
  387. if fight_time == 6 or waitFindImg_withBool([topo_img.box3,topo_img.box4], 1, 0) == True:
  388. if waitClickImg_withBool(topo_img.refresh,2,1) == True:
  389. waitClickImg_noWait_withBool(topo_img.button_ok,1,1)
  390. fight_time = 0
  391. time.sleep(1)
  392. break
  393. if waitClickImg_withBool(topo_img.refresh,2,1) == True:
  394. if waitClickImg_noWait_withBool(topo_img.button_ok,1,1) == False:
  395. return False
  396. return True
  397. class task_jiyang(yys_task):
  398. def __init__(self):
  399. super().__init__(f"结界寄养")
  400. def run(self):
  401. task_goto_place(PLACE.TOWN)
  402. if waitClickImg_withBool(yyl_img.head, 2, 1) == False:
  403. return False
  404. if waitClickImg_withBool(yyl_img.jiejie, 2, 1) == False:
  405. return False
  406. if waitClickImg_withBool(yyl_img.shishenGroup, 5, 3) == False:
  407. return False
  408. if waitClickImg_noWait_withBool(yyl_img.add_shishen, 5, 3) == False:
  409. return False
  410. if waitClickImg_withBool(yyl_img.enter_jiejie, 5, 3) == False:
  411. return False
  412. if waitFindImg_withBool(yyl_img.All_shishen, 5, 3) == False:
  413. return False
  414. while waitClickImg_withBool(yyl_img.enter, 1, 0.5) == False:
  415. ret, pos = waitFindImg(yyl_img.All_shishen, 2, 0.5)
  416. if ret == True:
  417. pcacc_mouse.click(pos[0] + 150, pos[1] - 90)
  418. return True
  419. class task_AddPerson(yys_task):
  420. def __init__(self, refreshTimes):
  421. super().__init__(f"阴阳寮加人{refreshTimes}次")
  422. self.refreshTimes = refreshTimes
  423. def run(self):
  424. task_goto_place(PLACE.TOWN)
  425. if waitClickImg_withBool(yyl_img.head, 2, 1) == False:
  426. return False
  427. if waitClickImg_withBool(yyl_img.liaoInfo, 2, 1) == False:
  428. return False
  429. if waitClickImg_withBool(yyl_img.manage, 2, 1) == False:
  430. return False
  431. retryTimes = 3
  432. while retryTimes > 0 and waitClickImg_noWait_withBool(yyl_img.manageBtn, 2, 1):
  433. if waitClickImg_withBool(yyl_img.addPeople, 2, 1):
  434. break
  435. else:
  436. retryTimes -= 1
  437. if retryTimes == 0:
  438. return False
  439. while self.refreshTimes > 0:
  440. if waitClickImg_noWait_withBool(yyl_img.add, 1, 0.4) == False:
  441. waitClickImg_noWait_withBool(yyl_img.refreshBtn, 1, 0.5)
  442. self.refreshTimes -= 1
  443. return True
  444. class task_fightzuidui(yys_task):
  445. def __init__(self):
  446. super().__init__(f"组队,100s超时")
  447. def run(self):
  448. task_goto_place(PLACE.TOWN)
  449. retryTimes = 40
  450. while True:
  451. if retryTimes <= 0:
  452. break
  453. retryTimes -= 1
  454. if waitFindImg_withBool([zudui_img.qiuqiu, zudui_img.pcacc_mini], 2, 0.5) == False:
  455. continue
  456. if waitClickImg_withBool(zudui_img.accept, 5, 0.5) == False:
  457. continue
  458. waitClickImg_withBool(zudui_img.accept, 2, 0.5)
  459. waitClickImg_withBool(zudui_img.accept, 2, 0.5)#防止没点到
  460. basic_operate.do_fight(60)
  461. retryTimes = 40
  462. class task_yuhun(yys_task):
  463. def __init__(self):
  464. super().__init__(f"御魂100次")
  465. def run(self):
  466. task_goto_place(PLACE.TOWN)
  467. tryTimes = 100
  468. if waitClickImg_withBool(zudui_img.zudui, 2, 1) == False:
  469. return False
  470. if waitFindImg_withBool(zudui_img.createTeam, 2, 1) == False:
  471. return False
  472. #已经进入页面
  473. while waitClickImg_noWait_withBool(zudui_img.yuhun, 2, 1) == False:
  474. yys_dragAuto(zudui_img.up_drag_begin)
  475. while waitClickImg_noWait_withBool(zudui_img.ten, 1, 1) == False:
  476. yys_dragAuto(zudui_img.mid_drag)
  477. if waitClickImg_withBool(zudui_img.createTeam, 5, 1) == False:
  478. return False
  479. waitClickImg_withBool(zudui_img.not_pubulic, 5, 1)
  480. if waitClickImg_withBool(zudui_img.create, 5, 1) == False:
  481. return False
  482. while tryTimes > 0:
  483. tryTimes -= 1
  484. while waitFindImg_withBool(zudui_img.pcacc2, 1, 0.5) == False:
  485. if waitClickImg_noWait_withBool(zudui_img.AddPerson, 5, 1) == False:
  486. return False
  487. if waitClickImg_noWait_withBool(zudui_img.pcacc, 5, 1) == False:
  488. return False
  489. if waitClickImg_withBool(zudui_img.invite, 5, 1) == False:
  490. return False
  491. if waitClickImg_withBool(zudui_img.attack, 10, 1) == False:
  492. return False
  493. basic_operate.do_fight(20)
  494. if waitClickImg_withBool(zudui_img.enter, 10, 1) == False:
  495. return False
  496. class task_fightYaoqi(yys_task):
  497. def __init__(self, type : YAOQI):
  498. super().__init__(f"妖气封印{type}")
  499. self.type = type
  500. def run(self):
  501. dstImg = None
  502. if self.type == YAOQI.GUISHIHEI:
  503. dstImg = zudui_img.guishihei
  504. elif self.type == YAOQI.RIHEFANG:
  505. dstImg = zudui_img.rihefang
  506. task_goto_place(PLACE.TOWN)
  507. if waitClickImg_withBool(zudui_img.zudui, 2, 1) == False:
  508. return False
  509. #if waitFindImg_withBool(zudui_img.createTeam, 2, 1) == False:
  510. # return False
  511. if waitFindImg_withBool(zudui_img.AutoPair, 1, 1) == False: #如果没找到自动匹配,意味着需要重新拉取
  512. while waitClickImg_noWait_withBool(zudui_img.fengyin, 1, 1) == False:
  513. yys_dragAuto(zudui_img.left_drag_begin)
  514. while waitClickImg_noWait_withBool(dstImg, 1, 1) == False:
  515. yys_dragAuto(zudui_img.mid_drag)
  516. if waitClickImg_withBool(zudui_img.AutoPair, 2, 1) == False:
  517. return False
  518. return basic_operate.do_fight(300)
  519. class task_douji(yys_task):
  520. def __init__(self, tryTimes):
  521. super().__init__(f"斗技{tryTimes}次")
  522. self.tryTimes = tryTimes
  523. def run(self):
  524. task_goto_place(PLACE.OUTSIDE)
  525. if waitClickImg_withBool(douji_img.douji, 10, 5) == False:
  526. return False
  527. while self.tryTimes > 0:
  528. if waitClickImg_withBool([douji_img.fight,douji_img.fight2], 10, 5) == False:
  529. return False
  530. if waitClickImg_withBool([public_img.fight_begin,douji_img.AutoGo], 20, 5) == False:
  531. return False
  532. myTimeSleep_big()
  533. waitClickImg_withBool([douji_img.AutoGo,douji_img.shoudong], 10, 5)
  534. while waitClickImg_withBool([public_img.fight_fail, douji_img.success], 10, 1) == False:
  535. ret,pos = waitFindImg(douji_img.shuju, 1, 0)
  536. if ret:
  537. pcacc_mouse.click(pos[0] - 100, pos[1] - 100)
  538. myTimeSleep_small()
  539. self.tryTimes -=1
  540. return True
  541. class task_baigui(yys_task):
  542. def __init__(self):
  543. super().__init__("百鬼夜行40次")
  544. def run(self):
  545. task_goto_place(PLACE.OUTSIDE)
  546. if waitClickImg_withBool(baigui_img.head, 10, 5) == False:
  547. return False
  548. tryTimes = 40
  549. while tryTimes > 0:
  550. tryTimes -= 1
  551. waitClickImg_noWait_withBool(baigui_img.invite, 4, 1)
  552. waitClickImg_withBool(baigui_img.friend, 4, 1)
  553. if waitClickImg_withBool(baigui_img.enter, 10, 2) == False:
  554. return False
  555. myTimeSleep_big()
  556. pointArr = []
  557. pointArr.append(get_yys_random_point(baigui_img.left))
  558. pointArr.append(get_yys_random_point(baigui_img.mid))
  559. pointArr.append(get_yys_random_point(baigui_img.right))
  560. random.shuffle(pointArr)
  561. for point in pointArr:
  562. pcacc_mouse.click(point[0], point[1])
  563. myTimeSleep_small()
  564. if waitClickImg_withBool(baigui_img.begin, 3, 1) == False:
  565. return False
  566. myTimeSleep_big()
  567. ret, position = find_yys_pos()
  568. while waitFindImg_withBool([baigui_img.end, baigui_img.invite], 0.1, 0) == False:
  569. pointArr = []
  570. ret, pos = pcacc_img.find_imgs(baigui_img.pic1)
  571. if ret == False:
  572. pointArr.append((baigui_img.pos1, baigui_img.pic1))
  573. ret, pos = pcacc_img.find_imgs(baigui_img.pic2)
  574. if ret == False:
  575. pointArr.append((baigui_img.pos2, baigui_img.pic2))
  576. ret, pos = pcacc_img.find_imgs(baigui_img.pic3)
  577. if ret == False:
  578. pointArr.append((baigui_img.pos3, baigui_img.pic3))
  579. ret, pos = pcacc_img.find_imgs(baigui_img.pic4)
  580. if ret == False:
  581. pointArr.append((baigui_img.pos4, baigui_img.pic4))
  582. random.shuffle(pointArr)
  583. for point in pointArr:
  584. dst = (point[0][0] + random.randint(-10, 10) + position[0], point[0][1] + random.randint(-10, 10) + position[1])
  585. while True:
  586. ret, pos = pcacc_img.find_imgs(place_img.back2)
  587. if ret:
  588. pcacc_mouse.quickclick(dst[0], dst[1])
  589. ret, pos = pcacc_img.find_imgs(point[1])
  590. if ret == False:
  591. break
  592. pcacc_mouse.quickclick(dst[0], dst[1])
  593. else:
  594. break
  595. waitClickImg_withBool(baigui_img.end, 3, 1)
  596. if __name__ == '__main__':
  597. # 移动鼠标
  598. #computer_name = task_getComputerName()
  599. #print(f"Computer Name: {computer_name}")
  600. myTimeSleep_big()
  601. #task_xiaohaochaoguiwang().run()
  602. task_zhaohuan().run()
  603. task_yeyuanhuo().run()
  604. while True:
  605. task_fightYaoqi(YAOQI.RIHEFANG).run()
  606. task_baigui().run()
  607. tmpRet, tmpPos = find_window_pos('Mumu模拟器12')
  608. pyautogui.screenshot(imageFilename='yys.png', region=tmpPos)
  609. #print(task_goto_place(PLACE.OUTSIDE))