dongri_task.py 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  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. if self.isAddStrenghth and basic_operate.get_line_num() >= 5:
  416. return False
  417. if waitFindImg_withBool(monster_img.search, 2, 1):
  418. myTimeSleep_big()
  419. yys_dragAuto(monster_img.move_right)
  420. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  421. return False
  422. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  423. return False
  424. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  425. return False
  426. if self.line != None:
  427. waitClickImg_noWait_withBool(self.line, 2, 1)
  428. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  429. return False
  430. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  431. maxTryTimes = 3
  432. while maxTryTimes > 0:
  433. maxTryTimes -= 1
  434. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  435. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  436. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  437. break
  438. return True
  439. class task_train(dongri_task):
  440. def __init__(self, train_type = None):
  441. super().__init__(f"检查训练{train_type}")
  442. self.train_type = train_type
  443. def run(self):
  444. basic_operate.go_town()
  445. if self.train_type == 'None':
  446. return True
  447. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  448. return False
  449. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  450. return False
  451. tryTimes = 3
  452. while tryTimes > 0:
  453. tryTimes -= 1
  454. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  455. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  456. break
  457. if self.train_type == 'lv1':
  458. myTimeSleep_big()
  459. yys_dragAuto(train_img.move_left)
  460. yys_dragAuto(train_img.move_left)
  461. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  462. elif self.train_type == 'lv8':
  463. waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
  464. elif self.train_type == 'lv9':
  465. waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
  466. return basic_operate.enter_auto_supply_resource(train_img.begin_train)
  467. class task_checkHelp(dongri_task):
  468. def __init__(self, isOutSide = False):
  469. super().__init__(f"检查帮助")
  470. self.isOutSide = isOutSide
  471. def run(self):
  472. if self.isOutSide:
  473. basic_operate.go_outside()
  474. else:
  475. basic_operate.go_town()
  476. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  477. return True
  478. class task_checkStoreRoom(dongri_task):
  479. def __init__(self):
  480. super().__init__(f"检查仓库或招募")
  481. def run(self):
  482. basic_operate.go_town()
  483. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  484. return False
  485. myTimeSleep_big()
  486. yys_dragAuto(check_img.move_down)
  487. yys_dragAuto(check_img.move_down)
  488. myTimeSleep_big()
  489. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  490. return False
  491. myTimeSleep_big()
  492. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
  493. myTimeSleep_big()
  494. pcacc_mouse.quickclick_current()
  495. myTimeSleep_big()
  496. waitClickImg_noWait_withBool((check_img.detail,check_img.detail2), 2, 1)
  497. myTimeSleep_big()
  498. basic_operate.go_town()
  499. myTimeSleep_big()
  500. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  501. return False
  502. myTimeSleep_big()
  503. pcacc_mouse.quickclick_current()
  504. myTimeSleep_big()
  505. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  506. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  507. else:
  508. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  509. myTimeSleep_big()
  510. dstPos = get_yys_random_point(check_img.pet_getRegion)
  511. pcacc_mouse.click(dstPos[0], dstPos[1])
  512. myTimeSleep_big()
  513. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  514. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  515. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  516. return True
  517. class task_checkConfilits(dongri_task):
  518. def __init__(self):
  519. super().__init__(f"检查集结")
  520. def run(self):
  521. basic_operate.go_outside()
  522. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  523. return False
  524. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  525. return False
  526. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  527. return False
  528. return True
  529. class task_checkDonata(dongri_task):
  530. def __init__(self):
  531. super().__init__(f"检查捐献")
  532. def run(self):
  533. basic_operate.go_town()
  534. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  535. return False
  536. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  537. return False
  538. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  539. return False
  540. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  541. return False
  542. else:
  543. maxTryTimes = 3
  544. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  545. maxTryTimes -= 1
  546. return True
  547. class task_checkAdventure(dongri_task):
  548. def __init__(self):
  549. super().__init__(f"检查冒险")
  550. def run(self):
  551. basic_operate.go_town()
  552. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  553. return False
  554. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  555. return False
  556. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  557. return False
  558. return True
  559. class task_waitTime(dongri_task):
  560. def __init__(self):
  561. super().__init__(f"等待时间")
  562. def run(self):
  563. myTimeSleep(300)
  564. class check_buildOrResearch(dongri_task):
  565. def __init__(self):
  566. super().__init__(f"检查建筑或研究")
  567. def run(self):
  568. basic_operate.go_town()
  569. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  570. return False
  571. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  572. return False
  573. dstType = 'none'
  574. while True:
  575. 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):
  576. dstType = 'build'
  577. break
  578. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  579. if not handRet:
  580. return False
  581. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  582. dstPos = [0, 0]
  583. if not detailRet:
  584. # 如果找不到详细信息,兵营之类的,需点中间
  585. dstPos = [handPos[0] - 70, handPos[1] + 120]
  586. else:
  587. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  588. tryTimes = 5
  589. while tryTimes > 0:
  590. tryTimes -= 1
  591. myTimeSleep_big()
  592. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  593. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  594. dstType = 'research'
  595. break
  596. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  597. dstType = 'build'
  598. break
  599. break
  600. if dstType == 'none':
  601. print('没有找到建筑或研究')
  602. return False
  603. elif dstType == 'build':
  604. buildtimes = 4
  605. 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]):
  606. buildtimes -= 1
  607. if buildtimes == 0:
  608. break
  609. continue
  610. elif dstType == 'research':
  611. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  612. return False
  613. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  614. return False
  615. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  616. return True
  617. class task_information(dongri_task):
  618. def __init__(self, isAddStrengh = False):
  619. super().__init__(f"检查情报")
  620. self.isAddStrengh = isAddStrengh
  621. def run(self):
  622. basic_operate.go_outside()
  623. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  624. if self.isAddStrengh:
  625. basic_operate.add_strength()
  626. basic_operate.go_outside()
  627. else:
  628. print("没有足够的体力了")
  629. return False
  630. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  631. return False
  632. if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 0.5, 0.5):
  633. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  634. return False
  635. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  636. return False
  637. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  638. return False
  639. myTimeSleep_big()
  640. return True
  641. elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 0.5, 0.5):
  642. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  643. return False
  644. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  645. return False
  646. return True
  647. elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 0.5, 0.5):
  648. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  649. return False
  650. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  651. return False
  652. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  653. return False
  654. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  655. return False
  656. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  657. maxTryTimes = 3
  658. while maxTryTimes > 0:
  659. maxTryTimes -= 1
  660. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  661. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  662. break
  663. return True
  664. else:
  665. return False
  666. class task_returnAllLine(dongri_task):
  667. def __init__(self):
  668. super().__init__(f"返回所有路线")
  669. def run(self):
  670. basic_operate.go_outside()
  671. basic_operate.return_line()
  672. basic_operate.return_line()
  673. basic_operate.return_line()
  674. basic_operate.return_line()
  675. basic_operate.return_line()
  676. basic_operate.return_line()
  677. return True
  678. class task_paticipateInTeam(dongri_task):
  679. def __init__(self):
  680. super().__init__(f"参与队伍")
  681. def run(self):
  682. basic_operate.go_outside()
  683. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  684. return False
  685. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
  686. return False
  687. while True:
  688. if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
  689. break
  690. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  691. break
  692. if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
  693. break
  694. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  695. break
  696. break
  697. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  698. return False
  699. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  700. maxTryTimes = 3
  701. while maxTryTimes > 0:
  702. maxTryTimes -= 1
  703. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  704. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  705. break
  706. return True
  707. class task_cure(dongri_task):
  708. def __init__(self, continueCure = False, cureNum = None):
  709. super().__init__(f"治疗")
  710. self.continueCure = continueCure
  711. self.cureNum = cureNum
  712. def run(self):
  713. basic_operate.go_outside()
  714. if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  715. return False
  716. if self.continueCure == False:
  717. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  718. return False
  719. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  720. return False
  721. else:
  722. maxTryTimes = 50
  723. while waitClickImg_noWait_withBool((check_img.cure, check_img.help4), 30, 1) and maxTryTimes >= 0:
  724. maxTryTimes -= 1
  725. continue
  726. return True
  727. class task_useAnnimalSkill(dongri_task):
  728. def __init__(self):
  729. super().__init__(f"使用动物技能")
  730. def run(self):
  731. basic_operate.go_outside()
  732. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  733. return False
  734. if waitClickImg_noWait_withBool((check_img.wolf_skill, check_img.elephant_skill), 2, 1) == False:
  735. return False
  736. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  737. return False
  738. class task_activity_lianmeng(dongri_task):
  739. def __init__(self):
  740. super().__init__(f"联盟总动员")
  741. def run(self):
  742. basic_operate.go_town()
  743. if waitClickImg_noWait_withBool(special_activity_img.normal, 2, 1) == False:
  744. return False
  745. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2), 2, 1) == False:
  746. return False
  747. waitClickImg_noWait_withBool(special_activity_img.task_done, 2, 1)
  748. if waitFindImg_withBool(special_activity_img.doing_task, 2, 1) == False:
  749. if waitClickImg_noWait_withBool((special_activity_img.shili_120, special_activity_img.shili_860, special_activity_img.bigMonster), 2, 1) == True:
  750. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  751. return False
  752. if waitFindImg_withBool((special_activity_img.shili_120, special_activity_img.shili_860), 2, 1) == False:
  753. maxTryTimes = 2
  754. while waitClickImg_noWait_withBool((special_activity_img.owning, special_activity_img.owning_120), 2, 1) == True:
  755. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  756. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  757. maxTryTimes -= 1
  758. if maxTryTimes <= 0:
  759. break
  760. return True
  761. class task_checkMaster(dongri_task):
  762. def __init__(self):
  763. super().__init__(f"检查统帅")
  764. def run(self):
  765. basic_operate.go_town()
  766. if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
  767. return False
  768. if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
  769. return False
  770. myTimeSleep_big()
  771. pcacc_mouse.quickclick_current()
  772. if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
  773. return False
  774. return True
  775. class task_checkActivities(dongri_task):
  776. def __init__(self):
  777. super().__init__(f"检查各种活动时间")
  778. def find_all_matching_events(parts, input_word):
  779. results = []
  780. # 查找所有包含输入关键词的项
  781. matches = [i for i, part in enumerate(parts) if input_word in part]
  782. for match_index in matches:
  783. # 从匹配项开始向后查找第一个时间或状态
  784. for i in range(match_index + 1, len(parts)):
  785. current_part = parts[i]
  786. # 检查是否是时间(如 19:30)或状态(如 已结束)
  787. if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
  788. dst = {"item":parts[match_index], "time":current_part}
  789. results.append(dst)
  790. break # 找到第一个匹配就停止
  791. return results
  792. def run(self):
  793. global todo_msg, todo_list
  794. basic_operate.go_outside()
  795. if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
  796. return False
  797. if waitFindImg_withBool(check_img.todoList, 2, 1) == False:
  798. return False
  799. activityStr = yys_ocrAuto(check_img.todo_region)
  800. if activityStr:
  801. todo_msg = activityStr
  802. print(todo_msg)
  803. result = []
  804. '''
  805. ['北京时间', '2025-04-01', '据点争夺', '07:00', '3级科技工程站']
  806. judianArr = self.find_all_matching_events(activityStr, "据点")
  807. result.extend(judianArr)
  808. baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
  809. result.extend(baoleiArr)
  810. juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
  811. result.extend(juxiongArr)
  812. yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
  813. result.extend(yaosaiArr)
  814. todo_list = result
  815. '''
  816. return activityStr
  817. if __name__ == '__main__':
  818. task_fight_jina_only().run()
  819. #task_checkConfilits().run()
  820. #task_checkActivities().run()
  821. #task_checkMaster().run()
  822. #basic_operate.get_line_num()
  823. #yys_ocrAuto(check_img.line_orc)
  824. #basic_operate.go_town()
  825. #basic_operate.add_strength()
  826. #task_fightMonster(False, False,False).run()
  827. #task_checkHelp().run()
  828. #task_checkStoreRoom().run()
  829. #task_activity_lianmeng().run()
  830. #task_fight_yongbing(True).run()
  831. #task_collect([4,3,2,1]).run()
  832. #task_train("lv9").run()
  833. #task_information().run()
  834. #check_buildOrResearch().run()
  835. #task_checkDonata().run()
  836. #task_collect(1).run()
  837. #task_collect(2).run()
  838. #task_collect(3).run()
  839. #task_collect(4).run()
  840. #task_returnAllLine().run()
  841. #task_paticipateInTeam().run()
  842. #task_fight_jina(True).run()