yys_task.py 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  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. subprocess.Popen(R'C:\Program Files\Netease\MuMu Player 12\shell\MuMuPlayer.exe')
  124. if waitClickImg_withBool(gameStart_img.ico, 100, 20) == False:
  125. return False
  126. waitFindImg_withBool(gameStart_img.gameIn, 100, 10)
  127. while waitFindImg_withBool(gameStart_img.gameIn, 5, 10) == False:
  128. x1, y1 = get_yys_random_point((120, 120, 120, 120))
  129. pcacc_mouse.click(x1, y1)
  130. myTimeSleep(10)
  131. while waitFindImg_withBool(place_img.Town, 5, 5) == False:
  132. x1, y1 = get_yys_random_point(gameStart_img.enterGame)
  133. pcacc_mouse.click(x1, y1)
  134. isSuccess = True
  135. myTimeSleep_big()
  136. return isSuccess
  137. class yys_task:
  138. def __init__(self, name):
  139. self.name = name
  140. def run(self):
  141. print(f"Running task: {self.name}")
  142. def task_daoguan():
  143. waitClickImg_withBool(public_img.fight_begin, 3, 0)
  144. class task_yeyuanhuo(yys_task):
  145. def __init__(self):
  146. super().__init__(f"打业原火XXX100次")
  147. def run(self):
  148. tryTimes = 100
  149. while tryTimes > 0:
  150. tryTimes -= 1
  151. 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
  152. , public_img.guiwangFight], 10, 0)
  153. basic_operate.do_fight()
  154. class task_zhaohuan(yys_task):
  155. def __init__(self):
  156. super().__init__(f"召唤100次")
  157. def run(self):
  158. tryTimes = 100
  159. while tryTimes > 0:
  160. tryTimes = tryTimes - 1
  161. waitClickImg_withBool(special_img.zhaohuan, 1, 3)
  162. class task_chaoguiwang(yys_task):
  163. def __init__(self):
  164. super().__init__(f"打超鬼王4次")
  165. def run(self):
  166. tryTimes = 4
  167. while tryTimes > 0:
  168. '''
  169. if True == waitClickImg_noWait_withBool(chaoguiwang_img.xiaohao, 2, 0):
  170. myTimeSleep_big()
  171. waitClickImg_withBool(public_img.guiwang, 10, 0)
  172. myTimeSleep_big()
  173. waitClickImg_noWait(chaoguiwang_img.jijie, 3, 0)
  174. myTimeSleep_big()
  175. waitClickImg_noWait(chaoguiwang_img.kongbai, 2, 0)
  176. myTimeSleep_big()
  177. waitClickImg_noWait(zudui_img.invite, 5, 1)
  178. myTimeSleep_big()
  179. waitClickImg_noWait(chaoguiwang_img.main, 10, 0)
  180. myTimeSleep(60)
  181. '''
  182. task_goto_place(PLACE.TOWN)
  183. myTimeSleep_big()
  184. waitClickImg(chaoguiwang_img.first, 2, 0)
  185. myTimeSleep_big()
  186. waitClickImg(chaoguiwang_img.second, 2, 0)
  187. myTimeSleep_big()
  188. #waitClickImg(chaoguiwang_img.monster, 2, 0)
  189. #myTimeSleep_big()
  190. waitClickImg(public_img.guiwang, 2, 0)
  191. myTimeSleep_big()
  192. curTime = 3
  193. while curTime > 0:
  194. curTime = curTime - 1
  195. waitClickImg_noWait(chaoguiwang_img.normal, 1, 1)
  196. if False == waitClickImg_withBool(public_img.guiwangFight, 10, 0):
  197. break
  198. basic_operate.do_fight()
  199. myTimeSleep(20)
  200. tryTimes = tryTimes - 1
  201. return True
  202. class task_xiaohaochaoguiwang(yys_task):
  203. def __init__(self):
  204. super().__init__(f"小号打超鬼王10次")
  205. def run(self):
  206. while True:
  207. myTimeSleep_big()
  208. waitClickImg(chaoguiwang_img.xiaohao, 2, 0)
  209. myTimeSleep_big()
  210. waitClickImg_withBool(public_img.guiwang, 10, 0)
  211. myTimeSleep_big()
  212. waitClickImg_noWait(chaoguiwang_img.jijie, 3, 0)
  213. myTimeSleep_big()
  214. waitClickImg_noWait(chaoguiwang_img.kongbai, 2, 0)
  215. myTimeSleep_big()
  216. waitClickImg_noWait(zudui_img.invite, 5, 1)
  217. myTimeSleep(60)
  218. waitClickImg_noWait(chaoguiwang_img.main, 10, 0)
  219. task_goto_place(PLACE.TOWN)
  220. myTimeSleep_big()
  221. waitClickImg(chaoguiwang_img.first, 2, 0)
  222. myTimeSleep_big()
  223. waitClickImg(chaoguiwang_img.second, 2, 0)
  224. myTimeSleep_big()
  225. waitClickImg(chaoguiwang_img.monster, 2, 2)
  226. while True:
  227. task_goto_place(PLACE.TOWN)
  228. myTimeSleep_big()
  229. waitClickImg(chaoguiwang_img.first, 2, 0)
  230. myTimeSleep_big()
  231. waitClickImg(chaoguiwang_img.second, 2, 0)
  232. myTimeSleep_big()
  233. if False == waitClickImg(chaoguiwang_img.monster, 2, 2):
  234. break
  235. while True:
  236. if False == waitClickImg_withBool(public_img.guiwangFight, 10, 0):
  237. break
  238. basic_operate.do_fight()
  239. myTimeSleep(20)
  240. return True
  241. class task_tansuo(yys_task):
  242. def __init__(self, num, easy=False):
  243. super().__init__(f"探索第{num}章")
  244. self.num = num
  245. self.easy = easy
  246. def run(self):
  247. task_goto_place(PLACE.SEARCH)
  248. #滑动到第一章
  249. template = tansuo_img.zhangjie
  250. num_sel = template.format(self.num)
  251. if waitClickImg_withBool(num_sel,1,1) == False:#一般使最后一章,先尝试查找
  252. if waitClickImg_withBool(tansuo_img.tansuo,2,1) == False:#正常打完在再次探索页面
  253. if self.num < 20:
  254. max_tryTime = 10
  255. while max_tryTime > 0 and waitFindImg_withBool(template.format(1),0.4,1) == False:
  256. yys_dragAuto(tansuo_img.select_drag_up)
  257. max_tryTime -=1
  258. max_tryTime = 10
  259. while max_tryTime > 0 and waitClickImg_withBool(num_sel,0.4,1) == False:
  260. yys_dragAuto(tansuo_img.select_drag_down)
  261. max_tryTime -=1
  262. #随意,不影响结果
  263. if self.easy == True:
  264. waitClickImg_withBool(tansuo_img.easy,0.4,1)
  265. else:
  266. waitClickImg_withBool(tansuo_img.kunnan,0.4,1)
  267. if waitClickImg_withBool(tansuo_img.tansuo,2,1) == False:
  268. task_goto_place(PLACE.SEARCH)
  269. #滑动到第一章
  270. template = tansuo_img.zhangjie
  271. num_sel = template.format(self.num)
  272. end = [1083+(random.randint(0,30)),600+(random.randint(0,30))]
  273. start = [1077+(random.randint(0,30)),304+(random.randint(0,30))]
  274. if waitClickImg_withBool(tansuo_img.tansuo,2,1) == False:#正常打完在再次探索页面
  275. max_tryTime = 10
  276. while max_tryTime > 0 and waitFindImg_withBool(template.format(1),0.4,1) == False:
  277. yys_dragAuto(tansuo_img.select_drag_up)
  278. max_tryTime -=1
  279. max_tryTime = 10
  280. while max_tryTime > 0 and waitClickImg_withBool(num_sel,0.4,1) == False:
  281. yys_dragAuto(tansuo_img.select_drag_down)
  282. max_tryTime -=1
  283. #随意,不影响结果
  284. if self.easy == True:
  285. waitClickImg_withBool(tansuo_img.easy,0.4,1)
  286. else:
  287. waitClickImg_withBool(tansuo_img.kunnan,0.4,1)
  288. if waitClickImg_withBool(tansuo_img.tansuo,2,1) == False:
  289. return False
  290. drag_times = 30
  291. while drag_times > 0 and waitClickImg_withBool([tansuo_img.boss, tansuo_img.boss2, tansuo_img.boss3], 0.4, 0.4) == False:
  292. if waitClickImg_withBool(tansuo_img.xiaoguai, 1, 1):
  293. if waitFindImg_withBool(tansuo_img.backIco, 1, 1):
  294. drag_times = 30
  295. continue
  296. basic_operate.do_fight(0)
  297. waitFindImg(tansuo_img.backIco, 10, 1)
  298. else:
  299. yys_dragAuto(tansuo_img.tansuo_drag)
  300. drag_times-=1
  301. if drag_times == 0:
  302. print("拖动到没有小怪的地方了")
  303. return False
  304. basic_operate.do_fight(0)
  305. waitFindImg(tansuo_img.backIco, 10, 1)
  306. #寻找小纸人宝箱
  307. while waitClickImg_withBool(tansuo_img.box, 3 ,1) == True:
  308. ret,pos = waitFindImg(tansuo_img.box_get, 3, 1)
  309. if ret:
  310. pcacc_mouse.click(pos[0]+random.randint(150,300),pos[1]-random.randint(100,120))
  311. if waitFindImg_withBool(tansuo_img.box_get, 1, 1):
  312. pcacc_mouse.click(pos[0]+random.randint(150,300),pos[1]-random.randint(100,120))
  313. if waitClickImg_withBool([tansuo_img.big_box,tansuo_img.big_box2,tansuo_img.big_box3],3,0) == True:
  314. if waitClickImg_withBool(tansuo_img.big_box_get,2,1) == False:
  315. return False
  316. return True
  317. class task_pata(yys_task):
  318. def __init__(self):
  319. super().__init__("爬塔")
  320. def run(self):
  321. waitClickImg(special_img.tiaozhan, 10, 1)
  322. basic_operate.do_fight(0)
  323. class task_topo(yys_task):
  324. def __init__(self, retryTimes, person = True):
  325. if person:
  326. super().__init__("个人突破")
  327. else:
  328. super().__init__("阴阳寮突破")
  329. self.retryTimes = retryTimes
  330. self.person = person
  331. def run(self):
  332. while self.retryTimes:
  333. self.retryTimes = self.retryTimes - 1
  334. task_goto_place(PLACE.SEARCH)
  335. fail_time = 0
  336. fight_time = 0
  337. if waitClickImg_withBool(topo_img.topo,2,1) == False:
  338. return False
  339. if self.person == False:
  340. waitClickImg_withBool(topo_img.liaotopo, 2, 1)
  341. for i in range(5, -1, -1):
  342. myTimeSleep_big()
  343. star = topo_img.star
  344. sel = star.format(i)
  345. positions =list(pyautogui.locateAllOnScreen(sel, confidence=0.85))
  346. for position in positions:
  347. #pyautogui.screenshot(imageFilename='yys_tmp.png', region=position)
  348. region = (position[0] - 30,position[1]-100,280,150)
  349. #pyautogui.screenshot(imageFilename='yys2.png', region=region)
  350. myTimeSleep_big()
  351. ret = pcacc_img.find_img_in_area(topo_img.fail, region)
  352. ret2 = pcacc_img.find_img_in_area(topo_img.fail2, region)
  353. ret3 = pcacc_img.find_img_in_area(topo_img.fail3, region)
  354. print(f'find {sel}, {position}, {ret}, {ret2}, {ret3}')
  355. if pcacc_img.find_img_in_area(sel, region) == False:
  356. continue
  357. if ret == False and ret2 == False and ret3 == False:
  358. click_pos = pcacc_img.choose_one_point_from_position(position)
  359. star_tryTimes = 3
  360. #点击star位置
  361. while star_tryTimes>0 and waitFindImg_withBool(topo_img.fight,2,1) == False:
  362. pcacc_mouse.click(click_pos[0], click_pos[1])
  363. star_tryTimes-=1
  364. myTimeSleep_small()
  365. fight_tryTimes = 3
  366. while fight_tryTimes>0 and waitFindImg_withBool(topo_img.fight,2,1) == True:
  367. if waitClickImg_withBool(topo_img.fight,2,1) == False:
  368. return False
  369. fight_tryTimes-=1
  370. myTimeSleep_small()
  371. if fight_tryTimes == 0:
  372. return False
  373. basic_operate.do_fight()
  374. if waitClickImg_withBool(tansuo_img.big_box_get,2,1) == True:
  375. print("tupo宝箱获取")
  376. waitFindImg(topo_img.tupo_title, 10, 2)
  377. myTimeSleep_small()
  378. if waitFindImg_withBool(topo_img.box3, 1, 0) == True:
  379. break
  380. fight_time+=1
  381. #打满5次后刷新
  382. if fight_time == 6 or waitFindImg_withBool([topo_img.box3,topo_img.box4], 1, 0) == True:
  383. if waitClickImg_withBool(topo_img.refresh,2,1) == True:
  384. waitClickImg_noWait_withBool(topo_img.button_ok,1,1)
  385. fight_time = 0
  386. time.sleep(1)
  387. break
  388. if waitClickImg_withBool(topo_img.refresh,2,1) == True:
  389. if waitClickImg_noWait_withBool(topo_img.button_ok,1,1) == False:
  390. return False
  391. return True
  392. class task_jiyang(yys_task):
  393. def __init__(self):
  394. super().__init__(f"结界寄养")
  395. def run(self):
  396. task_goto_place(PLACE.TOWN)
  397. if waitClickImg_withBool(yyl_img.head, 2, 1) == False:
  398. return False
  399. if waitClickImg_withBool(yyl_img.jiejie, 2, 1) == False:
  400. return False
  401. if waitClickImg_withBool(yyl_img.shishenGroup, 5, 3) == False:
  402. return False
  403. if waitClickImg_noWait_withBool(yyl_img.add_shishen, 5, 3) == False:
  404. return False
  405. if waitClickImg_withBool(yyl_img.enter_jiejie, 5, 3) == False:
  406. return False
  407. if waitFindImg_withBool(yyl_img.All_shishen, 5, 3) == False:
  408. return False
  409. while waitClickImg_withBool(yyl_img.enter, 1, 0.5) == False:
  410. ret, pos = waitFindImg(yyl_img.All_shishen, 2, 0.5)
  411. if ret == True:
  412. pcacc_mouse.click(pos[0] + 150, pos[1] - 90)
  413. return True
  414. class task_AddPerson(yys_task):
  415. def __init__(self, refreshTimes):
  416. super().__init__(f"阴阳寮加人{refreshTimes}次")
  417. self.refreshTimes = refreshTimes
  418. def run(self):
  419. task_goto_place(PLACE.TOWN)
  420. if waitClickImg_withBool(yyl_img.head, 2, 1) == False:
  421. return False
  422. if waitClickImg_withBool(yyl_img.liaoInfo, 2, 1) == False:
  423. return False
  424. if waitClickImg_withBool(yyl_img.manage, 2, 1) == False:
  425. return False
  426. retryTimes = 3
  427. while retryTimes > 0 and waitClickImg_noWait_withBool(yyl_img.manageBtn, 2, 1):
  428. if waitClickImg_withBool(yyl_img.addPeople, 2, 1):
  429. break
  430. else:
  431. retryTimes -= 1
  432. if retryTimes == 0:
  433. return False
  434. while self.refreshTimes > 0:
  435. if waitClickImg_noWait_withBool(yyl_img.add, 1, 0.4) == False:
  436. waitClickImg_noWait_withBool(yyl_img.refreshBtn, 1, 0.5)
  437. self.refreshTimes -= 1
  438. return True
  439. class task_fightzuidui(yys_task):
  440. def __init__(self):
  441. super().__init__(f"组队,100s超时")
  442. def run(self):
  443. task_goto_place(PLACE.TOWN)
  444. retryTimes = 40
  445. while True:
  446. if retryTimes <= 0:
  447. break
  448. retryTimes -= 1
  449. if waitFindImg_withBool([zudui_img.qiuqiu, zudui_img.pcacc_mini], 2, 0.5) == False:
  450. continue
  451. if waitClickImg_withBool(zudui_img.accept, 5, 0.5) == False:
  452. continue
  453. waitClickImg_withBool(zudui_img.accept, 2, 0.5)
  454. waitClickImg_withBool(zudui_img.accept, 2, 0.5)#防止没点到
  455. basic_operate.do_fight(60)
  456. retryTimes = 40
  457. class task_yuhun(yys_task):
  458. def __init__(self):
  459. super().__init__(f"御魂100次")
  460. def run(self):
  461. task_goto_place(PLACE.TOWN)
  462. tryTimes = 100
  463. if waitClickImg_withBool(zudui_img.zudui, 2, 1) == False:
  464. return False
  465. if waitFindImg_withBool(zudui_img.createTeam, 2, 1) == False:
  466. return False
  467. #已经进入页面
  468. while waitClickImg_noWait_withBool(zudui_img.yuhun, 2, 1) == False:
  469. yys_dragAuto(zudui_img.up_drag_begin)
  470. while waitClickImg_noWait_withBool(zudui_img.ten, 1, 1) == False:
  471. yys_dragAuto(zudui_img.mid_drag)
  472. if waitClickImg_withBool(zudui_img.createTeam, 5, 1) == False:
  473. return False
  474. waitClickImg_withBool(zudui_img.not_pubulic, 5, 1)
  475. if waitClickImg_withBool(zudui_img.create, 5, 1) == False:
  476. return False
  477. while tryTimes > 0:
  478. tryTimes -= 1
  479. while waitFindImg_withBool(zudui_img.pcacc2, 1, 0.5) == False:
  480. if waitClickImg_noWait_withBool(zudui_img.AddPerson, 5, 1) == False:
  481. return False
  482. if waitClickImg_noWait_withBool(zudui_img.pcacc, 5, 1) == False:
  483. return False
  484. if waitClickImg_withBool(zudui_img.invite, 5, 1) == False:
  485. return False
  486. if waitClickImg_withBool(zudui_img.attack, 10, 1) == False:
  487. return False
  488. basic_operate.do_fight(20)
  489. if waitClickImg_withBool(zudui_img.enter, 10, 1) == False:
  490. return False
  491. class task_fightYaoqi(yys_task):
  492. def __init__(self, type : YAOQI):
  493. super().__init__(f"妖气封印{type}")
  494. self.type = type
  495. def run(self):
  496. dstImg = None
  497. if self.type == YAOQI.GUISHIHEI:
  498. dstImg = zudui_img.guishihei
  499. elif self.type == YAOQI.RIHEFANG:
  500. dstImg = zudui_img.rihefang
  501. task_goto_place(PLACE.TOWN)
  502. if waitClickImg_withBool(zudui_img.zudui, 2, 1) == False:
  503. return False
  504. #if waitFindImg_withBool(zudui_img.createTeam, 2, 1) == False:
  505. # return False
  506. if waitFindImg_withBool(zudui_img.AutoPair, 1, 1) == False: #如果没找到自动匹配,意味着需要重新拉取
  507. while waitClickImg_noWait_withBool(zudui_img.fengyin, 1, 1) == False:
  508. yys_dragAuto(zudui_img.left_drag_begin)
  509. while waitClickImg_noWait_withBool(dstImg, 1, 1) == False:
  510. yys_dragAuto(zudui_img.mid_drag)
  511. if waitClickImg_withBool(zudui_img.AutoPair, 2, 1) == False:
  512. return False
  513. return basic_operate.do_fight(300)
  514. class task_douji(yys_task):
  515. def __init__(self, tryTimes):
  516. super().__init__(f"斗技{tryTimes}次")
  517. self.tryTimes = tryTimes
  518. def run(self):
  519. task_goto_place(PLACE.OUTSIDE)
  520. if waitClickImg_withBool(douji_img.douji, 10, 5) == False:
  521. return False
  522. while self.tryTimes > 0:
  523. if waitClickImg_withBool([douji_img.fight,douji_img.fight2], 10, 5) == False:
  524. return False
  525. if waitClickImg_withBool([public_img.fight_begin,douji_img.AutoGo], 20, 5) == False:
  526. return False
  527. myTimeSleep_big()
  528. waitClickImg_withBool([douji_img.AutoGo,douji_img.shoudong], 10, 5)
  529. while waitClickImg_withBool([public_img.fight_fail, douji_img.success], 10, 1) == False:
  530. ret,pos = waitFindImg(douji_img.shuju, 1, 0)
  531. if ret:
  532. pcacc_mouse.click(pos[0] - 100, pos[1] - 100)
  533. myTimeSleep_small()
  534. self.tryTimes -=1
  535. return True
  536. class task_baigui(yys_task):
  537. def __init__(self):
  538. super().__init__("百鬼夜行40次")
  539. def run(self):
  540. task_goto_place(PLACE.OUTSIDE)
  541. if waitClickImg_withBool(baigui_img.head, 10, 5) == False:
  542. return False
  543. tryTimes = 40
  544. while tryTimes > 0:
  545. tryTimes -= 1
  546. waitClickImg_noWait_withBool(baigui_img.invite, 4, 1)
  547. waitClickImg_withBool(baigui_img.friend, 4, 1)
  548. if waitClickImg_withBool(baigui_img.enter, 10, 2) == False:
  549. return False
  550. myTimeSleep_big()
  551. pointArr = []
  552. pointArr.append(get_yys_random_point(baigui_img.left))
  553. pointArr.append(get_yys_random_point(baigui_img.mid))
  554. pointArr.append(get_yys_random_point(baigui_img.right))
  555. random.shuffle(pointArr)
  556. for point in pointArr:
  557. pcacc_mouse.click(point[0], point[1])
  558. myTimeSleep_small()
  559. if waitClickImg_withBool(baigui_img.begin, 3, 1) == False:
  560. return False
  561. myTimeSleep_big()
  562. ret, position = find_yys_pos()
  563. while waitFindImg_withBool([baigui_img.end, baigui_img.invite], 0.1, 0) == False:
  564. pointArr = []
  565. ret, pos = pcacc_img.find_imgs(baigui_img.pic1)
  566. if ret == False:
  567. pointArr.append((baigui_img.pos1, baigui_img.pic1))
  568. ret, pos = pcacc_img.find_imgs(baigui_img.pic2)
  569. if ret == False:
  570. pointArr.append((baigui_img.pos2, baigui_img.pic2))
  571. ret, pos = pcacc_img.find_imgs(baigui_img.pic3)
  572. if ret == False:
  573. pointArr.append((baigui_img.pos3, baigui_img.pic3))
  574. ret, pos = pcacc_img.find_imgs(baigui_img.pic4)
  575. if ret == False:
  576. pointArr.append((baigui_img.pos4, baigui_img.pic4))
  577. random.shuffle(pointArr)
  578. for point in pointArr:
  579. dst = (point[0][0] + random.randint(-10, 10) + position[0], point[0][1] + random.randint(-10, 10) + position[1])
  580. while True:
  581. ret, pos = pcacc_img.find_imgs(place_img.back2)
  582. if ret:
  583. pcacc_mouse.quickclick(dst[0], dst[1])
  584. ret, pos = pcacc_img.find_imgs(point[1])
  585. if ret == False:
  586. break
  587. pcacc_mouse.quickclick(dst[0], dst[1])
  588. else:
  589. break
  590. waitClickImg_withBool(baigui_img.end, 3, 1)
  591. if __name__ == '__main__':
  592. # 移动鼠标
  593. #computer_name = task_getComputerName()
  594. #print(f"Computer Name: {computer_name}")
  595. myTimeSleep_big()
  596. #task_xiaohaochaoguiwang().run()
  597. task_zhaohuan().run()
  598. task_yeyuanhuo().run()
  599. while True:
  600. task_fightYaoqi(YAOQI.RIHEFANG).run()
  601. task_baigui().run()
  602. tmpRet, tmpPos = find_window_pos('Mumu模拟器12')
  603. pyautogui.screenshot(imageFilename='yys.png', region=tmpPos)
  604. #print(task_goto_place(PLACE.OUTSIDE))