dongri_task.py 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  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 waitClickImg_noWait_withBool(check_img.yongbing, 2, 1) == False:
  207. return False
  208. waitClickImg_noWait_withBool(check_img.detect, 2, 1)
  209. if waitClickImg_noWait_withBool(check_img.yongbing_fight, 2, 1) == False:
  210. return False
  211. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  212. return False
  213. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  214. return False
  215. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  216. return False
  217. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  218. maxTryTimes = 3
  219. while maxTryTimes > 0:
  220. maxTryTimes -= 1
  221. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  222. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  223. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  224. break
  225. return True
  226. class task_fight_jina_only(dongri_task):
  227. def __init__(self):
  228. super().__init__("战斗召唤的吉娜")
  229. def run(self):
  230. basic_operate.go_outside()
  231. #必须加体力
  232. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  233. basic_operate.add_strength()
  234. basic_operate.go_outside()
  235. if waitClickImg_noWait_withBool((check_img.talk_in,check_img.talk_in2), 2, 1) == False:
  236. return False
  237. waitClickImg_noWait_withBool(check_img.talkin_person, 2, 1)
  238. if waitClickImg_noWait_withBool(check_img.talkin_jina, 2, 1) == False:
  239. return False
  240. myTimeSleep_big()
  241. yys_dragAuto(check_img.move_down)
  242. yys_dragAuto(check_img.move_down)
  243. myTimeSleep_big()
  244. if waitClickImg_noWait_withBool(check_img.xiaohao_jina, 2, 1) == False:
  245. return False
  246. if waitClickImg_noWait_withBool((check_img.jina_pic, check_img.jina_pic2), 2, 1) == False:
  247. return False
  248. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  249. return False
  250. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  251. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  252. return False
  253. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  254. return False
  255. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  256. return False
  257. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  258. maxTryTimes = 3
  259. while maxTryTimes > 0:
  260. maxTryTimes -= 1
  261. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  262. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  263. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  264. break
  265. return True
  266. class task_call_jina(dongri_task):
  267. def __init__(self):
  268. super().__init__("召唤吉娜")
  269. def run(self):
  270. basic_operate.go_outside()
  271. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  272. return False
  273. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  274. return False
  275. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  276. return False
  277. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  278. return False
  279. if waitClickImg_noWait_withBool(check_img.share, 2, 1) == False:
  280. return False
  281. if waitClickImg_noWait_withBool(check_img.to_pcacc, 2, 1) == False:
  282. return False
  283. if waitClickImg_noWait_withBool(check_img.share_btn, 2, 1) == False:
  284. return False
  285. return True
  286. class task_fight_jina(dongri_task):
  287. def __init__(self, add_strengh):
  288. super().__init__("战斗吉娜")
  289. self.add_strengh = add_strengh
  290. def run(self):
  291. basic_operate.go_outside()
  292. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  293. if self.add_strengh:
  294. basic_operate.add_strength()
  295. basic_operate.go_outside()
  296. else:
  297. print("没有足够的体力了")
  298. return False
  299. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  300. return False
  301. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  302. return False
  303. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  304. return False
  305. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  306. return False
  307. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  308. return False
  309. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  310. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  311. return False
  312. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  313. return False
  314. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  315. return False
  316. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  317. maxTryTimes = 3
  318. while maxTryTimes > 0:
  319. maxTryTimes -= 1
  320. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  321. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  322. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  323. break
  324. return True
  325. class task_fightMonster(dongri_task):
  326. def __init__(self, add_strengh, fight_bigMonster, isSimple):
  327. self.add_strengh = add_strengh
  328. self.isSimple = isSimple
  329. if fight_bigMonster == True:
  330. super().__init__(f"战斗大怪物")
  331. self.monster = monster_img.bigMonster
  332. self.attack = monster_img.muti_team
  333. else:
  334. super().__init__(f"战斗小怪物")
  335. self.monster = monster_img.wolf
  336. self.attack = monster_img.attack
  337. def run(self):
  338. basic_operate.go_outside()
  339. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  340. if self.add_strengh:
  341. basic_operate.add_strength()
  342. basic_operate.go_outside()
  343. else:
  344. print("没有足够的体力了")
  345. return False
  346. if False == basic_operate.click_outside_search():
  347. return False
  348. if self.add_strengh and basic_operate.get_line_num() >= 6:
  349. return False
  350. if waitFindImg_withBool(monster_img.search, 2, 1):
  351. myTimeSleep_big()
  352. yys_dragAuto(monster_img.move_left)
  353. if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
  354. return False
  355. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  356. return False
  357. if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
  358. return False
  359. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  360. if not self.isSimple:
  361. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  362. return False
  363. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  364. return False
  365. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  366. return False
  367. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  368. maxTryTimes = 3
  369. while maxTryTimes > 0:
  370. maxTryTimes -= 1
  371. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  372. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  373. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  374. break
  375. return True
  376. class task_collect(dongri_task):
  377. def __init__(self, type = 0, isSimple = False, isAddStrenghth = False):
  378. self.isSimple = isSimple
  379. self.isAddStrenghth = isAddStrenghth
  380. if isinstance(type, (list, tuple)):
  381. typeArr = type
  382. type = typeArr[random.randint(0, len(typeArr) - 1)]
  383. elif type == 0:
  384. typeArr = [4,4,3,3,3,2,2,2,1,1]
  385. type = typeArr[random.randint(0, len(typeArr) - 1)]
  386. elif type == 5:
  387. typeArr = [2,1]
  388. type = typeArr[random.randint(0, len(typeArr) - 1)]
  389. if type == 1:
  390. self.type = monster_img.meat
  391. self.line = monster_img.line2
  392. super().__init__(f"采集肉")
  393. elif type == 2:
  394. self.type = monster_img.wood
  395. self.line = monster_img.line3
  396. super().__init__(f"采集木头")
  397. elif type == 3:
  398. self.type = monster_img.mine
  399. self.line = monster_img.line4
  400. super().__init__(f"采矿石")
  401. elif type == 4:
  402. self.type = monster_img.iron
  403. self.line = monster_img.line5
  404. super().__init__(f"采集铁矿石")
  405. else:
  406. self.type = None
  407. self.line = None
  408. super().__init__(f"采集None")
  409. if isSimple:
  410. self.line = None
  411. def run(self):
  412. if self.type == None:
  413. return True
  414. basic_operate.go_outside()
  415. maxLineNum = 6
  416. if self.isSimple:
  417. if self.isAddStrenghth:
  418. maxLineNum = 3
  419. else:
  420. maxLineNum = 4
  421. else:
  422. if self.isAddStrenghth:
  423. maxLineNum = 5
  424. else:
  425. maxLineNum = 6
  426. if basic_operate.get_line_num() >= maxLineNum:
  427. return False
  428. if False == basic_operate.click_outside_search():
  429. return False
  430. if waitFindImg_withBool(monster_img.search, 2, 1):
  431. myTimeSleep_big()
  432. yys_dragAuto(monster_img.move_right)
  433. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  434. return False
  435. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  436. return False
  437. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  438. return False
  439. if self.line != None:
  440. waitClickImg_noWait_withBool(self.line, 2, 1)
  441. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  442. return False
  443. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  444. maxTryTimes = 3
  445. while maxTryTimes > 0:
  446. maxTryTimes -= 1
  447. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  448. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  449. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  450. break
  451. return True
  452. class task_train(dongri_task):
  453. def __init__(self, train_type = None):
  454. super().__init__(f"检查训练{train_type}")
  455. self.train_type = train_type
  456. def run(self):
  457. basic_operate.go_town()
  458. if self.train_type == 'None':
  459. return True
  460. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  461. return False
  462. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  463. return False
  464. tryTimes = 3
  465. while tryTimes > 0:
  466. tryTimes -= 1
  467. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  468. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  469. break
  470. if self.train_type == 'lv1':
  471. myTimeSleep_big()
  472. yys_dragAuto(train_img.move_left)
  473. yys_dragAuto(train_img.move_left)
  474. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  475. elif self.train_type == 'lv8':
  476. waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
  477. elif self.train_type == 'lv9':
  478. waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
  479. return basic_operate.enter_auto_supply_resource(train_img.begin_train)
  480. class task_checkHelp(dongri_task):
  481. def __init__(self, isOutSide = False):
  482. super().__init__(f"检查帮助")
  483. self.isOutSide = isOutSide
  484. def run(self):
  485. if self.isOutSide:
  486. basic_operate.go_outside()
  487. else:
  488. basic_operate.go_town()
  489. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  490. return True
  491. class task_gotoTree(dongri_task):
  492. def __init__(self):
  493. super().__init__(f"查看生命之树")
  494. def run(self):
  495. basic_operate.go_town()
  496. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  497. return False
  498. myTimeSleep_big()
  499. yys_dragAuto(check_img.move_down)
  500. yys_dragAuto(check_img.move_down)
  501. myTimeSleep_big()
  502. if waitClickImg_noWait_withBool(check_img.life_tree, 2, 1) == False:
  503. return False
  504. myTimeSleep_big()
  505. pcacc_mouse.quickclick_current()
  506. myTimeSleep_big()
  507. waitClickImg_noWait_withBool(check_img.life_jam, 2, 1)
  508. waitClickImg_noWait_withBool(check_img.life_jam, 2, 1)
  509. return True
  510. class task_checkStoreRoom(dongri_task):
  511. def __init__(self):
  512. super().__init__(f"检查仓库或招募")
  513. def run(self):
  514. basic_operate.go_town()
  515. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  516. return False
  517. myTimeSleep_big()
  518. yys_dragAuto(check_img.move_down)
  519. yys_dragAuto(check_img.move_down)
  520. myTimeSleep_big()
  521. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  522. return False
  523. myTimeSleep_big()
  524. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
  525. waitClickImg_noWait_withBool(check_img.bigGet, 2, 1)
  526. pcacc_mouse.quickclick_current()
  527. myTimeSleep_big()
  528. if waitClickImg_noWait_withBool((check_img.detail,check_img.detail2), 2, 1):
  529. myTimeSleep_big()
  530. basic_operate.go_town()
  531. myTimeSleep_big()
  532. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  533. return False
  534. myTimeSleep_big()
  535. pcacc_mouse.quickclick_current()
  536. myTimeSleep_big()
  537. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  538. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  539. else:
  540. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  541. myTimeSleep_big()
  542. dstPos = get_yys_random_point(check_img.pet_getRegion)
  543. pcacc_mouse.click(dstPos[0], dstPos[1])
  544. myTimeSleep_big()
  545. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  546. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  547. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  548. return True
  549. class task_checkConfilits(dongri_task):
  550. def __init__(self):
  551. super().__init__(f"检查集结")
  552. def run(self):
  553. basic_operate.go_outside()
  554. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  555. return False
  556. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  557. return False
  558. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  559. return False
  560. return True
  561. class task_checkDonata(dongri_task):
  562. def __init__(self):
  563. super().__init__(f"检查捐献")
  564. def run(self):
  565. basic_operate.go_town()
  566. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  567. return False
  568. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  569. return False
  570. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  571. return False
  572. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  573. return False
  574. else:
  575. maxTryTimes = 3
  576. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  577. maxTryTimes -= 1
  578. return True
  579. class task_checkAdventure(dongri_task):
  580. def __init__(self):
  581. super().__init__(f"检查冒险")
  582. def run(self):
  583. basic_operate.go_town()
  584. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  585. return False
  586. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  587. return False
  588. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  589. return False
  590. return True
  591. class task_waitTime(dongri_task):
  592. def __init__(self):
  593. super().__init__(f"等待时间")
  594. def run(self):
  595. myTimeSleep(300)
  596. class check_buildOrResearch(dongri_task):
  597. def __init__(self):
  598. super().__init__(f"检查建筑或研究")
  599. def run(self):
  600. basic_operate.go_town()
  601. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  602. return False
  603. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  604. return False
  605. dstType = 'none'
  606. while True:
  607. 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):
  608. dstType = 'build'
  609. break
  610. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  611. if not handRet:
  612. return False
  613. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  614. dstPos = [0, 0]
  615. if not detailRet:
  616. # 如果找不到详细信息,兵营之类的,需点中间
  617. dstPos = [handPos[0] - 70, handPos[1] + 120]
  618. else:
  619. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  620. tryTimes = 5
  621. while tryTimes > 0:
  622. tryTimes -= 1
  623. myTimeSleep_big()
  624. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  625. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  626. dstType = 'research'
  627. break
  628. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  629. dstType = 'build'
  630. break
  631. break
  632. if dstType == 'none':
  633. print('没有找到建筑或研究')
  634. return False
  635. elif dstType == 'build':
  636. buildtimes = 4
  637. 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]):
  638. buildtimes -= 1
  639. if buildtimes == 0:
  640. break
  641. continue
  642. elif dstType == 'research':
  643. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  644. return False
  645. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  646. return False
  647. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  648. return True
  649. class task_information(dongri_task):
  650. def __init__(self, isAddStrengh = False):
  651. super().__init__(f"检查情报")
  652. self.isAddStrengh = isAddStrengh
  653. def run(self):
  654. basic_operate.go_outside()
  655. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  656. if self.isAddStrengh:
  657. basic_operate.add_strength()
  658. basic_operate.go_outside()
  659. else:
  660. print("没有足够的体力了")
  661. return False
  662. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  663. return False
  664. if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 0.5, 0.5):
  665. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  666. return False
  667. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  668. return False
  669. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  670. return False
  671. myTimeSleep_big()
  672. return True
  673. elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 0.5, 0.5):
  674. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  675. return False
  676. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  677. return False
  678. return True
  679. elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 0.5, 0.5):
  680. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  681. return False
  682. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  683. return False
  684. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  685. return False
  686. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  687. return False
  688. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  689. maxTryTimes = 3
  690. while maxTryTimes > 0:
  691. maxTryTimes -= 1
  692. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  693. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  694. break
  695. return True
  696. else:
  697. return False
  698. class task_returnAllLine(dongri_task):
  699. def __init__(self):
  700. super().__init__(f"返回所有路线")
  701. def run(self):
  702. basic_operate.go_outside()
  703. basic_operate.return_line()
  704. basic_operate.return_line()
  705. basic_operate.return_line()
  706. basic_operate.return_line()
  707. basic_operate.return_line()
  708. basic_operate.return_line()
  709. return True
  710. class task_paticipateInTeam(dongri_task):
  711. def __init__(self):
  712. super().__init__(f"参与队伍")
  713. def run(self):
  714. basic_operate.go_outside()
  715. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  716. return False
  717. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
  718. return False
  719. while True:
  720. if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
  721. break
  722. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  723. break
  724. if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
  725. break
  726. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  727. break
  728. break
  729. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  730. return False
  731. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  732. maxTryTimes = 3
  733. while maxTryTimes > 0:
  734. maxTryTimes -= 1
  735. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  736. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  737. break
  738. return True
  739. class task_cure(dongri_task):
  740. def __init__(self, continueCure = False, cureNum = None):
  741. super().__init__(f"治疗")
  742. self.continueCure = continueCure
  743. self.cureNum = cureNum
  744. def run(self):
  745. basic_operate.go_outside()
  746. if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  747. return False
  748. if self.continueCure == False:
  749. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  750. return False
  751. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  752. return False
  753. else:
  754. maxTryTimes = 50
  755. while waitClickImg_noWait_withBool((check_img.cure, check_img.help4), 30, 1) and maxTryTimes >= 0:
  756. maxTryTimes -= 1
  757. continue
  758. return True
  759. class task_useAnnimalSkill(dongri_task):
  760. def __init__(self):
  761. super().__init__(f"使用动物技能")
  762. def run(self):
  763. basic_operate.go_outside()
  764. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  765. return False
  766. if waitClickImg_noWait_withBool((check_img.wolf_skill, check_img.elephant_skill), 2, 1) == False:
  767. return False
  768. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  769. return False
  770. class task_activity_lianmeng(dongri_task):
  771. def __init__(self):
  772. super().__init__(f"联盟总动员")
  773. def run(self):
  774. basic_operate.go_town()
  775. if waitClickImg_noWait_withBool(special_activity_img.normal, 2, 1) == False:
  776. return False
  777. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2), 2, 1) == False:
  778. return False
  779. waitClickImg_noWait_withBool(special_activity_img.task_done, 2, 1)
  780. if waitFindImg_withBool(special_activity_img.doing_task, 2, 1) == False:
  781. if waitClickImg_noWait_withBool((special_activity_img.shili_120, special_activity_img.shili_860_2, special_activity_img.bigMonster), 2, 1) == True:
  782. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  783. return False
  784. if waitFindImg_withBool((special_activity_img.shili_120, special_activity_img.shili_860_2), 2, 1) == False:
  785. maxTryTimes = 2
  786. while waitClickImg_noWait_withBool((special_activity_img.owning, special_activity_img.owning_120), 2, 1) == True:
  787. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  788. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  789. maxTryTimes -= 1
  790. if maxTryTimes <= 0:
  791. break
  792. return True
  793. class task_checkMaster(dongri_task):
  794. def __init__(self):
  795. super().__init__(f"检查统帅")
  796. def run(self):
  797. basic_operate.go_town()
  798. if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
  799. return False
  800. if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
  801. return False
  802. myTimeSleep_big()
  803. pcacc_mouse.quickclick_current()
  804. if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
  805. return False
  806. return True
  807. class task_checkActivities(dongri_task):
  808. def __init__(self):
  809. super().__init__(f"检查各种活动时间")
  810. def find_all_matching_events(self, parts, input_word):
  811. results = []
  812. # 查找所有包含输入关键词的项
  813. matches = [i for i, part in enumerate(parts) if input_word in part]
  814. for match_index in matches:
  815. # 从匹配项开始向后查找第一个时间或状态
  816. for i in range(match_index + 1, len(parts)):
  817. current_part = parts[i]
  818. # 检查是否是时间(如 19:30)或状态(如 已结束)
  819. if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
  820. dst = {"item":parts[match_index], "time":current_part}
  821. results.append(dst)
  822. break # 找到第一个匹配就停止
  823. return results
  824. def run(self):
  825. global todo_msg, todo_list
  826. basic_operate.go_outside()
  827. if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
  828. return False
  829. if waitFindImg_withBool(check_img.todoList, 2, 1) == False:
  830. return False
  831. activityStr = yys_ocrAuto(check_img.todo_region)
  832. if activityStr:
  833. todo_msg = activityStr
  834. print(todo_msg)
  835. result = []
  836. judianArr = self.find_all_matching_events(activityStr, "据点")
  837. result.extend(judianArr)
  838. baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
  839. result.extend(baoleiArr)
  840. juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
  841. result.extend(juxiongArr)
  842. yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
  843. result.extend(yaosaiArr)
  844. todo_list = result
  845. print(todo_list)
  846. return activityStr
  847. if __name__ == '__main__':
  848. #task_gotoTree().run()
  849. #task_fight_jina_only().run()
  850. #task_checkConfilits().run()
  851. #task_checkActivities().run()
  852. #task_checkMaster().run()
  853. #basic_operate.get_line_num()
  854. #yys_ocrAuto(check_img.line_orc)
  855. #basic_operate.go_town()
  856. #basic_operate.add_strength()
  857. #task_fightMonster(False, False,False).run()
  858. #task_checkHelp().run()
  859. #task_checkStoreRoom().run()
  860. #task_activity_lianmeng().run()
  861. task_fight_yongbing(True).run()
  862. #task_collect([4,3,2,1]).run()
  863. #task_train("lv9").run()
  864. #task_information().run()
  865. #check_buildOrResearch().run()
  866. #task_checkDonata().run()
  867. #task_collect(1).run()
  868. #task_collect(2).run()
  869. #task_collect(3).run()
  870. #task_collect(4).run()
  871. #task_returnAllLine().run()
  872. #task_paticipateInTeam().run()
  873. #task_fight_jina(True).run()