dongri_task.py 35 KB

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