dongri_task.py 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. # -*- coding: utf-8 -*-
  2. import threading
  3. from scriptBase.imgFind import pcacc_img, savePic
  4. from scriptBase.mouseClick import pcacc_mouse
  5. from scriptBase.ocr import capture_and_ocr
  6. import scriptBase.base
  7. from scriptBase.comon import *
  8. from scriptBase.ocr import *
  9. from apscheduler.schedulers.blocking import BlockingScheduler
  10. import pyautogui
  11. import random
  12. import sys
  13. import math
  14. import os
  15. import time
  16. from dongri_define import *
  17. from dongri_pic import *
  18. import subprocess
  19. import socket
  20. from dongri_pic import _imported
  21. '''
  22. 基础配置说明:
  23. 600*800(DPI 300)
  24. 游戏画面:流畅
  25. 高帧率关闭
  26. 町中模式:旧版
  27. '''
  28. todo_msg = ''
  29. todo_list = []
  30. def get_todo_msg():
  31. global todo_msg
  32. return todo_msg
  33. def get_todo_msgList():
  34. global todo_list
  35. todo_str = ''
  36. for item in todo_list:
  37. todo_str += f'{item["item"]}:{item["time"]}</br>'
  38. return todo_str
  39. def fing_todoList_time(taskStr):
  40. for item in todo_list:
  41. if item['task'] == taskStr:
  42. return item['time']
  43. def task_getComputerName():
  44. return socket.gethostname()
  45. def task_acceptTask():
  46. while True:
  47. myTimeSleep_big()
  48. def init():
  49. global _imported
  50. if not _imported:
  51. acceptTask = threading.Thread(target=task_acceptTask)
  52. acceptTask.daemon = True
  53. if acceptTask.is_alive() == False:
  54. acceptTask.start()
  55. _imported = True
  56. class basic_operate:
  57. @staticmethod
  58. def do_back():
  59. task_return_game()
  60. ret = False
  61. ret |= waitClickImg_noWait_withBool(place_img.back1, 0.6, 0)
  62. if ret:
  63. return
  64. ret |= waitClickImg_noWait_withBool(place_img.back2, 0.6, 0)
  65. if ret:
  66. return
  67. ret |= waitClickImg_noWait_withBool(place_img.back3, 0.6, 0)
  68. if ret:
  69. return
  70. ret, pos = waitFindImg(place_img.title, 1, 0)
  71. if ret:
  72. pcacc_mouse.click(pos[0] + 20, pos[1] + 80)
  73. def backToGame(preTime = 0):
  74. tryMaxTimes = 5
  75. while tryMaxTimes > 0:
  76. tryMaxTimes -= 1
  77. if waitFindImg_withBool(place_img.gameIn, 1, preTime) == False:
  78. basic_operate.do_back()
  79. else:
  80. return True
  81. return False
  82. @staticmethod
  83. def go_town(preTime = 0):
  84. if basic_operate.backToGame(preTime) == False:
  85. return False
  86. waitClickImg_noWait_withBool(place_img.outside, 0.6, 0)
  87. return True
  88. @staticmethod
  89. def go_outside(preTime = 0):
  90. if basic_operate.backToGame(preTime) == False:
  91. return False
  92. waitClickImg_noWait_withBool(place_img.town, 0.6, 0)
  93. return True
  94. @staticmethod
  95. def click_outside_search():
  96. taskListRet, taskListPos = waitFindImg(monster_img.tasklist, 2, 3)
  97. if taskListRet == False:
  98. return False
  99. else:
  100. pcacc_mouse.click(taskListPos[0], taskListPos[1] - 110)#click search
  101. myTimeSleep_big()
  102. return True
  103. @staticmethod
  104. def enter_auto_supply_resource(enter_pic):
  105. if waitClickImg_noWait_withBool(enter_pic, 2, 2) == False:
  106. return False
  107. if waitClickImg_noWait_withBool(train_img.getAll, 2, 1) == False:
  108. return True
  109. if waitClickImg_noWait_withBool(train_img.enter, 2, 1) == False:
  110. return False
  111. if waitClickImg_noWait_withBool(enter_pic, 2, 1) == False:
  112. return False
  113. return True
  114. @staticmethod
  115. def return_line():
  116. if waitClickImg_noWait_withBool(monster_img.returnLine, 2, 1) == False:
  117. return False
  118. if waitClickImg_noWait_withBool(monster_img.enter, 2, 1) == False:
  119. return False
  120. return True
  121. @staticmethod
  122. def add_strength():
  123. if waitClickImg_noWait_withBool(check_img.no_strength, 2, 1) == False:
  124. return False
  125. if waitClickImg_noWait_withBool(check_img.add_strength, 2, 1) == False:
  126. return False
  127. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  128. return False
  129. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  130. return False
  131. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  132. return False
  133. return True
  134. @staticmethod
  135. def get_line_num():
  136. lineStr = yys_ocrAuto(check_img.line_orc)
  137. if len(lineStr) == 0:
  138. return 0
  139. match = re.search(r'\d', lineStr[0]) # 查找第一个数字
  140. if match:
  141. first_digit = match.group()
  142. print("第一个数字:", first_digit)
  143. return int(first_digit)
  144. else:
  145. print("未找到数字")
  146. return 0
  147. def task_return_game():
  148. tryTimes = 3
  149. while tryTimes > 0:
  150. if False == waitFindImg_withBool([place_img.title], 1, 1):
  151. waitClickImg_noWait([place_img.ico, place_img.ico2], 1, 0)
  152. myTimeSleep_big()
  153. tryTimes -= 1
  154. if tryTimes == 0:
  155. return False
  156. else:
  157. break
  158. def task_save_compress_pic():
  159. # 截取屏幕截图
  160. screenshot = pyautogui.screenshot()
  161. compressed_data = compress_image(screenshot)
  162. # 保存压缩后的图像到文件
  163. with open('compressed_screenshot.jpg', 'wb') as f:
  164. f.write(compressed_data)
  165. def task_close_game():
  166. subprocess.call(f"taskkill /f /im MuMuPlayer.exe")
  167. subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
  168. subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
  169. myTimeSleep_big()
  170. def task_start_game():
  171. isSuccess = True
  172. path1 = R'C:\\Program Files\\Netease\\MuMuPlayer-12.0\\shell\\MuMuPlayer.exe'
  173. path2 = R'C:\Program Files\Netease\MuMu Player 12\shell\MuMuPlayer.exe'
  174. if os.path.exists(path1):
  175. subprocess.Popen(path1)
  176. elif os.path.exists(path2):
  177. subprocess.Popen(path2)
  178. if waitClickImg_withBool(gameStart_img.ico, 100, 20) == False:
  179. return False
  180. waitFindImg_withBool(place_img.gameIn, 10, 20)
  181. basic_operate.go_town()
  182. waitFindImg_withBool(place_img.gameIn, 10, 20)
  183. basic_operate.go_town()
  184. if waitFindImg_withBool(place_img.gameIn, 10, 20) == False:
  185. return False
  186. myTimeSleep_big()
  187. return isSuccess
  188. class dongri_task:
  189. def __init__(self, name):
  190. self.name = name
  191. def run(self):
  192. print(f"Running task: {self.name}")
  193. class task_fight_yongbing(dongri_task):
  194. def __init__(self, add_strengh):
  195. super().__init__("战斗佣兵")
  196. self.add_strengh = add_strengh
  197. def run(self):
  198. basic_operate.go_outside()
  199. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  200. if self.add_strengh:
  201. basic_operate.add_strength()
  202. basic_operate.go_outside()
  203. else:
  204. print("没有足够的体力了")
  205. return False
  206. if basic_operate.get_line_num() >= 6:
  207. return False
  208. if waitClickImg_noWait_withBool(check_img.yongbing, 2, 1) == False:
  209. return False
  210. waitClickImg_noWait_withBool(check_img.detect, 2, 1)
  211. if waitClickImg_noWait_withBool(check_img.yongbing_fight, 2, 1) == False:
  212. return False
  213. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  214. return False
  215. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  216. return False
  217. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  218. return False
  219. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  220. maxTryTimes = 3
  221. while maxTryTimes > 0:
  222. maxTryTimes -= 1
  223. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  224. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  225. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  226. break
  227. return True
  228. class task_fight_jina_only(dongri_task):
  229. def __init__(self):
  230. super().__init__("战斗召唤的吉娜")
  231. def run(self):
  232. basic_operate.go_outside()
  233. #必须加体力
  234. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  235. basic_operate.add_strength()
  236. basic_operate.go_outside()
  237. if waitClickImg_noWait_withBool((check_img.talk_in,check_img.talk_in2), 2, 1) == False:
  238. return False
  239. waitClickImg_noWait_withBool(check_img.talkin_person, 2, 1)
  240. if waitClickImg_noWait_withBool(check_img.talkin_jina, 2, 1) == False:
  241. return False
  242. myTimeSleep_big()
  243. yys_dragAuto(check_img.move_down)
  244. yys_dragAuto(check_img.move_down)
  245. myTimeSleep_big()
  246. if waitClickImg_noWait_withBool(check_img.xiaohao_jina, 2, 1) == False:
  247. return False
  248. if waitClickImg_noWait_withBool((check_img.jina_pic, check_img.jina_pic2), 2, 1) == False:
  249. return False
  250. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  251. return False
  252. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  253. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  254. return False
  255. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  256. return False
  257. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  258. return False
  259. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  260. maxTryTimes = 3
  261. while maxTryTimes > 0:
  262. maxTryTimes -= 1
  263. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  264. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  265. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  266. break
  267. return True
  268. class task_call_jina(dongri_task):
  269. def __init__(self):
  270. super().__init__("召唤吉娜")
  271. def run(self):
  272. basic_operate.go_outside()
  273. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  274. return False
  275. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  276. return False
  277. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  278. return False
  279. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  280. return False
  281. if waitClickImg_noWait_withBool(check_img.share, 2, 1) == False:
  282. return False
  283. if waitClickImg_noWait_withBool(check_img.to_pcacc, 2, 1) == False:
  284. return False
  285. if waitClickImg_noWait_withBool(check_img.share_btn, 2, 1) == False:
  286. return False
  287. return True
  288. class task_fight_jina(dongri_task):
  289. def __init__(self, add_strengh):
  290. super().__init__("战斗吉娜")
  291. self.add_strengh = add_strengh
  292. def run(self):
  293. basic_operate.go_outside()
  294. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  295. if self.add_strengh:
  296. basic_operate.add_strength()
  297. basic_operate.go_outside()
  298. else:
  299. print("没有足够的体力了")
  300. return False
  301. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  302. return False
  303. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  304. return False
  305. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  306. return False
  307. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  308. return False
  309. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  310. return False
  311. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  312. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  313. return False
  314. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  315. return False
  316. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  317. return False
  318. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  319. maxTryTimes = 3
  320. while maxTryTimes > 0:
  321. maxTryTimes -= 1
  322. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  323. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  324. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  325. break
  326. return True
  327. class task_fightMonster(dongri_task):
  328. def __init__(self, add_strengh, fight_bigMonster, isSimple):
  329. self.add_strengh = add_strengh
  330. self.isSimple = isSimple
  331. if fight_bigMonster == True:
  332. super().__init__(f"战斗大怪物")
  333. self.monster = monster_img.bigMonster
  334. self.attack = monster_img.muti_team
  335. else:
  336. super().__init__(f"战斗小怪物")
  337. self.monster = monster_img.wolf
  338. self.attack = monster_img.attack
  339. def run(self):
  340. basic_operate.go_outside()
  341. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  342. if self.add_strengh:
  343. basic_operate.add_strength()
  344. basic_operate.go_outside()
  345. else:
  346. print("没有足够的体力了")
  347. return False
  348. if False == basic_operate.click_outside_search():
  349. return False
  350. if self.add_strengh and basic_operate.get_line_num() >= 6:
  351. return False
  352. if waitFindImg_withBool(monster_img.search, 2, 1):
  353. myTimeSleep_big()
  354. yys_dragAuto(monster_img.move_left)
  355. if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
  356. return False
  357. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  358. return False
  359. if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
  360. return False
  361. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  362. if not self.isSimple:
  363. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  364. return False
  365. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  366. return False
  367. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  368. return False
  369. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  370. maxTryTimes = 3
  371. while maxTryTimes > 0:
  372. maxTryTimes -= 1
  373. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  374. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  375. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  376. break
  377. return True
  378. class task_collect(dongri_task):
  379. def __init__(self, type = 0, isSimple = False, isAddStrenghth = False):
  380. self.isSimple = isSimple
  381. self.isAddStrenghth = isAddStrenghth
  382. if isinstance(type, (list, tuple)):
  383. typeArr = type
  384. type = typeArr[random.randint(0, len(typeArr) - 1)]
  385. elif type == 0:
  386. typeArr = [4,4,3,3,3,2,2,2,1,1]
  387. type = typeArr[random.randint(0, len(typeArr) - 1)]
  388. elif type == 5:
  389. typeArr = [2,1]
  390. type = typeArr[random.randint(0, len(typeArr) - 1)]
  391. if type == 1:
  392. self.type = monster_img.meat
  393. self.line = monster_img.line2
  394. super().__init__(f"采集肉")
  395. elif type == 2:
  396. self.type = monster_img.wood
  397. self.line = monster_img.line3
  398. super().__init__(f"采集木头")
  399. elif type == 3:
  400. self.type = monster_img.mine
  401. self.line = monster_img.line4
  402. super().__init__(f"采矿石")
  403. elif type == 4:
  404. self.type = monster_img.iron
  405. self.line = monster_img.line5
  406. super().__init__(f"采集铁矿石")
  407. else:
  408. self.type = None
  409. self.line = None
  410. super().__init__(f"采集None")
  411. if isSimple:
  412. self.line = None
  413. def run(self):
  414. if self.type == None:
  415. return True
  416. basic_operate.go_outside()
  417. maxLineNum = 6
  418. if self.isSimple:
  419. if self.isAddStrenghth:
  420. maxLineNum = 3
  421. else:
  422. maxLineNum = 4
  423. else:
  424. if self.isAddStrenghth:
  425. maxLineNum = 5
  426. else:
  427. maxLineNum = 6
  428. if basic_operate.get_line_num() >= maxLineNum:
  429. return False
  430. if False == basic_operate.click_outside_search():
  431. return False
  432. if waitFindImg_withBool(monster_img.search, 2, 1):
  433. myTimeSleep_big()
  434. yys_dragAuto(monster_img.move_right)
  435. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  436. return False
  437. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  438. return False
  439. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  440. return False
  441. if self.line != None:
  442. waitClickImg_noWait_withBool(self.line, 2, 1)
  443. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  444. return False
  445. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  446. maxTryTimes = 3
  447. while maxTryTimes > 0:
  448. maxTryTimes -= 1
  449. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  450. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  451. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  452. break
  453. return True
  454. class task_train(dongri_task):
  455. def __init__(self, train_type = None):
  456. super().__init__(f"检查训练{train_type}")
  457. self.train_type = train_type
  458. def run(self):
  459. basic_operate.go_town()
  460. if self.train_type == 'None':
  461. return True
  462. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  463. return False
  464. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  465. return False
  466. tryTimes = 3
  467. while tryTimes > 0:
  468. tryTimes -= 1
  469. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  470. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  471. break
  472. if self.train_type == 'lv1':
  473. myTimeSleep_big()
  474. yys_dragAuto(train_img.move_left)
  475. yys_dragAuto(train_img.move_left)
  476. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  477. elif self.train_type == 'lv8':
  478. waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
  479. elif self.train_type == 'lv9':
  480. waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
  481. return basic_operate.enter_auto_supply_resource(train_img.begin_train)
  482. class task_checkHelp(dongri_task):
  483. def __init__(self, isOutSide = False):
  484. super().__init__(f"检查帮助")
  485. self.isOutSide = isOutSide
  486. def run(self):
  487. if self.isOutSide:
  488. basic_operate.go_outside()
  489. else:
  490. basic_operate.go_town()
  491. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  492. return True
  493. class task_gotoTree(dongri_task):
  494. def __init__(self):
  495. super().__init__(f"查看生命之树")
  496. def run(self):
  497. basic_operate.go_town()
  498. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  499. return False
  500. myTimeSleep_big()
  501. yys_dragAuto(check_img.move_down)
  502. yys_dragAuto(check_img.move_down)
  503. myTimeSleep_big()
  504. if waitClickImg_noWait_withBool(check_img.life_tree, 2, 1) == False:
  505. return False
  506. myTimeSleep_big()
  507. pcacc_mouse.quickclick_current()
  508. myTimeSleep_big()
  509. waitClickImg_noWait_withBool(check_img.life_jam, 2, 1)
  510. waitClickImg_noWait_withBool(check_img.life_jam, 2, 1)
  511. return True
  512. class task_checkStoreRoom(dongri_task):
  513. def __init__(self):
  514. super().__init__(f"检查仓库或招募")
  515. def run(self):
  516. basic_operate.go_town()
  517. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  518. return False
  519. myTimeSleep_big()
  520. yys_dragAuto(check_img.move_down)
  521. yys_dragAuto(check_img.move_down)
  522. myTimeSleep_big()
  523. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  524. return False
  525. myTimeSleep_big()
  526. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
  527. waitClickImg_noWait_withBool(check_img.bigGet, 2, 1)
  528. pcacc_mouse.quickclick_current()
  529. myTimeSleep_big()
  530. if waitClickImg_noWait_withBool((check_img.detail,check_img.detail2), 2, 1):
  531. myTimeSleep_big()
  532. basic_operate.go_town()
  533. myTimeSleep_big()
  534. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  535. return False
  536. myTimeSleep_big()
  537. pcacc_mouse.quickclick_current()
  538. myTimeSleep_big()
  539. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  540. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  541. else:
  542. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  543. myTimeSleep_big()
  544. dstPos = get_yys_random_point(check_img.pet_getRegion)
  545. pcacc_mouse.click(dstPos[0], dstPos[1])
  546. myTimeSleep_big()
  547. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  548. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  549. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  550. return True
  551. class task_checkConfilits(dongri_task):
  552. def __init__(self):
  553. super().__init__(f"检查集结")
  554. def run(self):
  555. basic_operate.go_outside()
  556. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  557. return False
  558. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  559. return False
  560. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  561. return False
  562. return True
  563. class task_checkDonata(dongri_task):
  564. def __init__(self):
  565. super().__init__(f"检查捐献")
  566. def run(self):
  567. basic_operate.go_town()
  568. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  569. return False
  570. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  571. return False
  572. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  573. return False
  574. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  575. return False
  576. else:
  577. maxTryTimes = 3
  578. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  579. maxTryTimes -= 1
  580. return True
  581. class task_checkAdventure(dongri_task):
  582. def __init__(self):
  583. super().__init__(f"检查冒险")
  584. def run(self):
  585. basic_operate.go_town()
  586. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  587. return False
  588. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  589. return False
  590. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  591. return False
  592. return True
  593. class task_waitTime(dongri_task):
  594. def __init__(self):
  595. super().__init__(f"等待时间")
  596. def run(self):
  597. myTimeSleep(300)
  598. class check_buildOrResearch(dongri_task):
  599. def __init__(self):
  600. super().__init__(f"检查建筑或研究")
  601. def run(self):
  602. basic_operate.go_town()
  603. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  604. return False
  605. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  606. return False
  607. dstType = 'none'
  608. while True:
  609. if waitFindImg_withBool([check_img.upgrade_done, check_img.upgrade_done2, check_img.upgrade_done3, check_img.upgrade_next, check_img.upgrade_done4], 2, 1):
  610. dstType = 'build'
  611. break
  612. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  613. if not handRet:
  614. return False
  615. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  616. dstPos = [0, 0]
  617. if not detailRet:
  618. # 如果找不到详细信息,兵营之类的,需点中间
  619. dstPos = [handPos[0] - 70, handPos[1] + 120]
  620. else:
  621. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  622. tryTimes = 5
  623. while tryTimes > 0:
  624. tryTimes -= 1
  625. myTimeSleep_big()
  626. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  627. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  628. dstType = 'research'
  629. break
  630. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  631. dstType = 'build'
  632. break
  633. break
  634. if dstType == 'none':
  635. print('没有找到建筑或研究')
  636. return False
  637. elif dstType == 'build':
  638. buildtimes = 4
  639. while basic_operate.enter_auto_supply_resource([check_img.upgrade_done, check_img.upgrade_done2, check_img.upgrade_done3, check_img.upgrade_next, check_img.upgrade_done4]):
  640. buildtimes -= 1
  641. if buildtimes == 0:
  642. break
  643. continue
  644. elif dstType == 'research':
  645. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  646. return False
  647. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  648. return False
  649. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  650. return True
  651. class task_information(dongri_task):
  652. def __init__(self, isAddStrengh = False):
  653. super().__init__(f"检查情报")
  654. self.isAddStrengh = isAddStrengh
  655. def run(self):
  656. basic_operate.go_outside()
  657. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  658. if self.isAddStrengh:
  659. basic_operate.add_strength()
  660. basic_operate.go_outside()
  661. else:
  662. print("没有足够的体力了")
  663. return False
  664. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  665. return False
  666. if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 0.5, 0.5):
  667. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  668. return False
  669. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  670. return False
  671. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  672. return False
  673. myTimeSleep_big()
  674. return True
  675. elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 0.5, 0.5):
  676. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  677. return False
  678. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  679. return False
  680. return True
  681. elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 0.5, 0.5):
  682. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  683. return False
  684. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  685. return False
  686. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  687. return False
  688. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  689. return False
  690. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  691. maxTryTimes = 3
  692. while maxTryTimes > 0:
  693. maxTryTimes -= 1
  694. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  695. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  696. break
  697. return True
  698. else:
  699. return False
  700. class task_returnAllLine(dongri_task):
  701. def __init__(self):
  702. super().__init__(f"返回所有路线")
  703. def run(self):
  704. basic_operate.go_outside()
  705. basic_operate.return_line()
  706. basic_operate.return_line()
  707. basic_operate.return_line()
  708. basic_operate.return_line()
  709. basic_operate.return_line()
  710. basic_operate.return_line()
  711. return True
  712. class task_paticipateInTeam(dongri_task):
  713. def __init__(self):
  714. super().__init__(f"参与队伍")
  715. def run(self):
  716. basic_operate.go_outside()
  717. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  718. return False
  719. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
  720. return False
  721. while True:
  722. if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
  723. break
  724. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  725. break
  726. if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
  727. break
  728. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  729. break
  730. break
  731. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  732. return False
  733. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  734. maxTryTimes = 3
  735. while maxTryTimes > 0:
  736. maxTryTimes -= 1
  737. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  738. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  739. break
  740. return True
  741. class task_cure(dongri_task):
  742. def __init__(self, continueCure = False, cureNum = None):
  743. super().__init__(f"治疗")
  744. self.continueCure = continueCure
  745. self.cureNum = cureNum
  746. def run(self):
  747. basic_operate.go_outside()
  748. if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  749. return False
  750. if self.continueCure == False:
  751. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  752. return False
  753. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  754. return False
  755. else:
  756. maxTryTimes = 50
  757. while waitClickImg_noWait_withBool((check_img.cure, check_img.help4), 30, 1) and maxTryTimes >= 0:
  758. maxTryTimes -= 1
  759. continue
  760. return True
  761. class task_useAnnimalSkill(dongri_task):
  762. def __init__(self):
  763. super().__init__(f"使用动物技能")
  764. def run(self):
  765. basic_operate.go_outside()
  766. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  767. return False
  768. if waitClickImg_noWait_withBool((check_img.wolf_skill, check_img.elephant_skill), 2, 1) == False:
  769. return False
  770. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  771. return False
  772. class task_activity_lianmeng(dongri_task):
  773. def __init__(self):
  774. super().__init__(f"联盟总动员")
  775. def run(self):
  776. basic_operate.go_town()
  777. if waitClickImg_noWait_withBool(special_activity_img.normal, 2, 1) == False:
  778. return False
  779. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2), 2, 1) == False:
  780. return False
  781. waitClickImg_noWait_withBool(special_activity_img.task_done, 2, 1)
  782. if waitFindImg_withBool(special_activity_img.doing_task, 2, 1) == False:
  783. if waitClickImg_noWait_withBool((special_activity_img.shili_120, special_activity_img.shili_860_2, special_activity_img.bigMonster), 2, 1) == True:
  784. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  785. return False
  786. if waitFindImg_withBool((special_activity_img.shili_120, special_activity_img.shili_860_2), 2, 1) == False:
  787. maxTryTimes = 2
  788. while waitClickImg_noWait_withBool((special_activity_img.owning, special_activity_img.owning_120), 2, 1) == True:
  789. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  790. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  791. maxTryTimes -= 1
  792. if maxTryTimes <= 0:
  793. break
  794. return True
  795. class task_checkMaster(dongri_task):
  796. def __init__(self):
  797. super().__init__(f"检查统帅")
  798. def run(self):
  799. basic_operate.go_town()
  800. if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
  801. return False
  802. if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
  803. return False
  804. myTimeSleep_big()
  805. pcacc_mouse.quickclick_current()
  806. if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
  807. return False
  808. return True
  809. class task_checkActivities(dongri_task):
  810. def __init__(self):
  811. super().__init__(f"检查各种活动时间")
  812. def find_all_matching_events(self, parts, input_word):
  813. results = []
  814. # 查找所有包含输入关键词的项
  815. matches = [i for i, part in enumerate(parts) if input_word in part]
  816. for match_index in matches:
  817. # 从匹配项开始向后查找第一个时间或状态
  818. for i in range(match_index + 1, len(parts)):
  819. current_part = parts[i]
  820. # 检查是否是时间(如 19:30)或状态(如 已结束)
  821. if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
  822. dst = {"item":parts[match_index], "time":current_part}
  823. results.append(dst)
  824. break # 找到第一个匹配就停止
  825. return results
  826. def run(self):
  827. global todo_msg, todo_list
  828. basic_operate.go_outside()
  829. if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
  830. return False
  831. if waitFindImg_withBool(check_img.todoList, 2, 1) == False:
  832. return False
  833. activityStr = yys_ocrAuto(check_img.todo_region)
  834. if activityStr:
  835. todo_msg = activityStr
  836. print(todo_msg)
  837. result = []
  838. judianArr = self.find_all_matching_events(activityStr, "据点")
  839. result.extend(judianArr)
  840. baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
  841. result.extend(baoleiArr)
  842. juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
  843. result.extend(juxiongArr)
  844. yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
  845. result.extend(yaosaiArr)
  846. todo_list = result
  847. print(todo_list)
  848. return activityStr
  849. class task_visit_island(dongri_task):
  850. def __init__(self):
  851. super().__init__(f"访问岛屿")
  852. def run(self):
  853. basic_operate.go_outside()
  854. if waitClickImg_noWait_withBool(check_img.visit_island_small, 2, 1) == False:
  855. return False
  856. if waitClickImg_noWait_withBool(check_img.visit_enter, 2, 1) == False:
  857. return False
  858. if waitClickImg_noWait_withBool(check_img.visit_island_big, 2, 1) == False:
  859. return False
  860. return True
  861. if __name__ == '__main__':
  862. #task_gotoTree().run()
  863. #task_fight_jina_only().run()
  864. #task_checkConfilits().run()
  865. #task_checkActivities().run()
  866. #task_checkMaster().run()
  867. #basic_operate.get_line_num()
  868. #yys_ocrAuto(check_img.line_orc)
  869. #basic_operate.go_town()
  870. #basic_operate.add_strength()
  871. #task_fightMonster(False, False,False).run()
  872. #task_checkHelp().run()
  873. #task_checkStoreRoom().run()
  874. #task_activity_lianmeng().run()
  875. task_fight_yongbing(True).run()
  876. #task_collect([4,3,2,1]).run()
  877. #task_train("lv9").run()
  878. #task_information().run()
  879. #check_buildOrResearch().run()
  880. #task_checkDonata().run()
  881. #task_collect(1).run()
  882. #task_collect(2).run()
  883. #task_collect(3).run()
  884. #task_collect(4).run()
  885. #task_returnAllLine().run()
  886. #task_paticipateInTeam().run()
  887. #task_fight_jina(True).run()