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