dongri_task.py 36 KB

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