dongri_task.py 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418
  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. from datetime import datetime, timedelta
  22. '''
  23. 基础配置说明:
  24. 600*800(DPI 300)
  25. 游戏画面:流畅
  26. 高帧率关闭
  27. 町中模式:旧版
  28. '''
  29. todo_msg = ''
  30. todo_list = []
  31. g_task_lineCheck = False
  32. def set_lineCheck(val):
  33. global g_task_lineCheck
  34. g_task_lineCheck = val
  35. def get_todo_msg():
  36. global todo_msg
  37. return todo_msg
  38. def get_todo_msgList():
  39. global todo_list
  40. todo_str = ''
  41. for item in todo_list:
  42. todo_str += f'{item["item"]}:{item["time"]}</br>'
  43. return todo_str
  44. def get_todo_time(todo_str):
  45. global todo_list
  46. for item in todo_list:
  47. if item['item'] == todo_str:
  48. return item['time']
  49. return None
  50. def is_within_n_minutes(target_time_str, n_minutes_left, n_minutes_right):
  51. if target_time_str == None:
  52. return False
  53. # 获取当前时间
  54. now = datetime.now()
  55. # 解析目标时间字符串
  56. try:
  57. target_time = datetime.strptime(target_time_str, "%H:%M")
  58. # 将目标时间的日期部分设置为当前日期
  59. target_time = target_time.replace(year=now.year, month=now.month, day=now.day)
  60. except ValueError:
  61. raise ValueError("时间格式应为'HH:MM'")
  62. # 计算时间范围
  63. start_time = target_time - timedelta(minutes=n_minutes_left)
  64. end_time = target_time + timedelta(minutes=n_minutes_right)
  65. # 检查当前时间是否在范围内
  66. return start_time <= now <= end_time
  67. def fing_todoList_time(taskStr):
  68. for item in todo_list:
  69. if item['task'] == taskStr:
  70. return item['time']
  71. def task_getComputerName():
  72. return socket.gethostname()
  73. def task_acceptTask():
  74. while True:
  75. myTimeSleep_big()
  76. def init():
  77. global _imported
  78. if not _imported:
  79. acceptTask = threading.Thread(target=task_acceptTask)
  80. acceptTask.daemon = True
  81. if acceptTask.is_alive() == False:
  82. acceptTask.start()
  83. _imported = True
  84. class basic_operate:
  85. @staticmethod
  86. def do_back():
  87. task_return_game()
  88. ret = False
  89. ret |= waitClickImg_noWait_withBool(place_img.back1, 0.6, 0)
  90. if ret:
  91. return
  92. ret |= waitClickImg_noWait_withBool(place_img.back2, 0.6, 0)
  93. if ret:
  94. return
  95. ret, pos = waitFindImg(place_img.title, 1, 0)
  96. if ret:
  97. pcacc_mouse.click(pos[0] + 20, pos[1] + 80)
  98. @staticmethod
  99. def backToGame(preTime = 0):
  100. tryMaxTimes = 5
  101. while tryMaxTimes > 0:
  102. tryMaxTimes -= 1
  103. if waitFindImg_withBool((place_img.gameIn, place_img.gameIn2), 1, preTime) == False:
  104. basic_operate.do_back()
  105. else:
  106. return True
  107. return False
  108. @staticmethod
  109. def go_town(preTime = 0):
  110. if basic_operate.backToGame(preTime) == False:
  111. return False
  112. waitClickImg_noWait_withBool(place_img.outside, 0.6, 0.5)
  113. return True
  114. @staticmethod
  115. def go_outside(preTime = 0):
  116. if basic_operate.backToGame(preTime) == False:
  117. return False
  118. waitClickImg_noWait_withBool(place_img.town, 0.6, 0.5)
  119. return True
  120. @staticmethod
  121. def click_outside_search():
  122. taskListRet, taskListPos = waitFindImg(monster_img.tasklist, 2, 3)
  123. if taskListRet == False:
  124. return False
  125. else:
  126. pcacc_mouse.click(taskListPos[0], taskListPos[1] - 110)#click search
  127. myTimeSleep_big()
  128. return True
  129. @staticmethod
  130. def enter_auto_supply_resource(enter_pic):
  131. if waitClickImg_noWait_withBool(enter_pic, 2, 2) == False:
  132. return False
  133. if waitClickImg_noWait_withBool(train_img.getAll, 2, 1) == False:
  134. return True
  135. if waitClickImg_noWait_withBool(train_img.enter, 2, 1) == False:
  136. return False
  137. if waitClickImg_noWait_withBool(enter_pic, 2, 1) == False:
  138. return False
  139. return True
  140. @staticmethod
  141. def return_line():
  142. if waitClickImg_noWait_withBool(monster_img.returnLine, 1, 0.5) == False:
  143. return False
  144. if waitClickImg_noWait_withBool(monster_img.enter, 2, 1) == False:
  145. return False
  146. return True
  147. @staticmethod
  148. def add_strength():
  149. if waitClickImg_noWait_withBool(check_img.no_strength, 2, 1) == False:
  150. return False
  151. if waitClickImg_noWait_withBool(check_img.add_strength, 2, 1) == False:
  152. return False
  153. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  154. return False
  155. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  156. return False
  157. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  158. return False
  159. return True
  160. @staticmethod
  161. def get_line_num():
  162. lineStr = yys_ocrAuto(check_img.line_orc)
  163. if len(lineStr) == 0:
  164. return 0
  165. match = re.search(r'\d', lineStr[0]) # 查找第一个数字
  166. if match:
  167. first_digit = match.group()
  168. print("第一个数字:", first_digit)
  169. return int(first_digit)
  170. else:
  171. print("未找到数字")
  172. return 0
  173. def task_return_game():
  174. tryTimes = 3
  175. while tryTimes > 0:
  176. if False == waitFindImg_withBool([place_img.title], 1, 1):
  177. waitClickImg_noWait([place_img.ico, place_img.ico2], 1, 0)
  178. myTimeSleep_big()
  179. tryTimes -= 1
  180. if tryTimes == 0:
  181. return False
  182. else:
  183. break
  184. def task_save_compress_pic():
  185. # 截取屏幕截图
  186. screenshot = pyautogui.screenshot()
  187. compressed_data = compress_image(screenshot)
  188. # 保存压缩后的图像到文件
  189. with open('compressed_screenshot.jpg', 'wb') as f:
  190. f.write(compressed_data)
  191. def task_close_game():
  192. subprocess.call(f"taskkill /f /im MuMuPlayer.exe")
  193. subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
  194. subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
  195. myTimeSleep_big()
  196. def task_start_game(type=0):
  197. isSuccess = True
  198. path1 = R'C:\\Program Files\\Netease\\MuMuPlayer-12.0\\shell\\MuMuPlayer.exe'
  199. path2 = R'C:\Program Files\Netease\MuMu Player 12\shell\MuMuPlayer.exe'
  200. if os.path.exists(path1):
  201. subprocess.Popen(path1)
  202. elif os.path.exists(path2):
  203. subprocess.Popen(path2)
  204. waitClickImg_withBool(gameStart_img.not_upgrade, 20, 10)
  205. if type == 0:
  206. if waitClickImg_withBool(gameStart_img.ico, 100, 0) == False:
  207. return False
  208. else:
  209. waitClickImg_withBool(gameStart_img.second_game, 100, 0)
  210. if waitClickImg_withBool(gameStart_img.ico, 5, 0) == False:
  211. return False
  212. waitFindImg_withBool(place_img.gameIn, 10, 20)
  213. basic_operate.go_town()
  214. waitFindImg_withBool(place_img.gameIn, 10, 20)
  215. basic_operate.go_town()
  216. if waitFindImg_withBool(place_img.gameIn, 10, 20) == False:
  217. return False
  218. myTimeSleep_big()
  219. return isSuccess
  220. class dongri_task:
  221. def __init__(self, name):
  222. self.name = name
  223. def run(self):
  224. print(f"Running task: {self.name}")
  225. class task_fight_yongbing(dongri_task):
  226. def __init__(self, add_strengh):
  227. super().__init__("战斗佣兵")
  228. self.add_strengh = add_strengh
  229. def run(self):
  230. basic_operate.go_outside()
  231. if False == waitFindImg_withBool(monster_img.enough_strengh2, 2, 1):
  232. if self.add_strengh:
  233. basic_operate.add_strength()
  234. basic_operate.go_outside()
  235. else:
  236. print("没有足够的体力了")
  237. return False
  238. if basic_operate.get_line_num() >= 6:
  239. return False
  240. if waitClickImg_noWait_withBool(check_img.yongbing, 2, 1) == False:
  241. return False
  242. waitClickImg_noWait_withBool(check_img.detect, 2, 1)
  243. if waitClickImg_noWait_withBool(check_img.yongbing_fight, 2, 1) == False:
  244. return False
  245. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  246. return False
  247. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  248. return False
  249. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  250. return False
  251. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  252. maxTryTimes = 3
  253. while maxTryTimes > 0:
  254. maxTryTimes -= 1
  255. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  256. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  257. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  258. break
  259. return True
  260. class task_fight_jina_only(dongri_task):
  261. def __init__(self):
  262. super().__init__("战斗召唤的吉娜")
  263. def run(self):
  264. basic_operate.go_outside()
  265. #必须加体力
  266. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  267. basic_operate.add_strength()
  268. basic_operate.go_outside()
  269. if waitClickImg_noWait_withBool((check_img.talk_in,check_img.talk_in2), 2, 1) == False:
  270. return False
  271. waitClickImg_noWait_withBool(check_img.talkin_person, 2, 1)
  272. if waitClickImg_noWait_withBool(check_img.talkin_jina, 2, 1) == False:
  273. return False
  274. myTimeSleep_big()
  275. yys_dragAuto(check_img.move_down)
  276. yys_dragAuto(check_img.move_down)
  277. myTimeSleep_big()
  278. if waitClickImg_noWait_withBool(check_img.xiaohao_jina, 2, 1) == False:
  279. return False
  280. if waitClickImg_noWait_withBool((check_img.jina_pic, check_img.jina_pic2), 2, 1) == False:
  281. return False
  282. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  283. return False
  284. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  285. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  286. return False
  287. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  288. return False
  289. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  290. return False
  291. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  292. maxTryTimes = 3
  293. while maxTryTimes > 0:
  294. maxTryTimes -= 1
  295. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  296. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  297. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  298. break
  299. return True
  300. class task_call_jina(dongri_task):
  301. def __init__(self):
  302. super().__init__("召唤吉娜")
  303. def run(self):
  304. basic_operate.go_outside()
  305. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  306. return False
  307. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  308. return False
  309. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  310. return False
  311. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  312. return False
  313. if waitClickImg_noWait_withBool(check_img.share, 2, 1) == False:
  314. return False
  315. if waitClickImg_noWait_withBool(check_img.to_pcacc, 2, 1) == False:
  316. return False
  317. if waitClickImg_noWait_withBool(check_img.share_btn, 2, 1) == False:
  318. return False
  319. return True
  320. class task_fight_jina(dongri_task):
  321. def __init__(self, add_strengh):
  322. super().__init__("战斗吉娜")
  323. self.add_strengh = add_strengh
  324. def run(self):
  325. basic_operate.go_outside()
  326. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  327. if self.add_strengh:
  328. basic_operate.add_strength()
  329. basic_operate.go_outside()
  330. else:
  331. print("没有足够的体力了")
  332. return False
  333. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  334. return False
  335. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  336. return False
  337. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  338. return False
  339. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  340. return False
  341. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  342. return False
  343. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  344. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  345. return False
  346. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  347. return False
  348. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  349. return False
  350. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  351. maxTryTimes = 3
  352. while maxTryTimes > 0:
  353. maxTryTimes -= 1
  354. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  355. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  356. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  357. break
  358. return True
  359. class task_fightMonster(dongri_task):
  360. def __init__(self, add_strengh, fight_bigMonster, isSimple):
  361. self.add_strengh = add_strengh
  362. self.isSimple = isSimple
  363. if fight_bigMonster == True:
  364. super().__init__(f"战斗大怪物")
  365. self.monster = monster_img.bigMonster
  366. self.attack = monster_img.muti_team
  367. else:
  368. super().__init__(f"战斗小怪物")
  369. self.monster = monster_img.wolf
  370. self.attack = monster_img.attack
  371. def run(self):
  372. global g_task_lineCheck
  373. basic_operate.go_outside()
  374. if False == waitFindImg_withBool((monster_img.enough_strengh2, monster_img.enough_strengh3), 2, 1):
  375. if self.add_strengh:
  376. basic_operate.add_strength()
  377. basic_operate.go_outside()
  378. else:
  379. print("没有足够的体力了")
  380. return False
  381. maxLineNum = 6
  382. if basic_operate.get_line_num() >= maxLineNum:
  383. return False
  384. if False == basic_operate.click_outside_search():
  385. return False
  386. if waitFindImg_withBool(monster_img.search, 2, 1):
  387. myTimeSleep_big()
  388. yys_dragAuto(monster_img.move_left)
  389. if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
  390. return False
  391. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  392. return False
  393. if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
  394. return False
  395. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  396. if not self.isSimple:
  397. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  398. return False
  399. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  400. return False
  401. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  402. return False
  403. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  404. maxTryTimes = 3
  405. while maxTryTimes > 0:
  406. maxTryTimes -= 1
  407. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  408. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  409. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  410. break
  411. return True
  412. class task_collect(dongri_task):
  413. def __init__(self, type = 0, isSimple = False, isAddStrenghth = False):
  414. self.isSimple = isSimple
  415. self.isAddStrenghth = isAddStrenghth
  416. if isinstance(type, (list, tuple)):
  417. typeArr = type
  418. type = typeArr[random.randint(0, len(typeArr) - 1)]
  419. elif type == 0:
  420. typeArr = [4,4,3,3,3,2,2,2,1,1]
  421. type = typeArr[random.randint(0, len(typeArr) - 1)]
  422. elif type == 5:
  423. typeArr = [2,1]
  424. type = typeArr[random.randint(0, len(typeArr) - 1)]
  425. if type == 1:
  426. self.type = monster_img.meat
  427. self.line = monster_img.line2
  428. super().__init__(f"采集肉")
  429. elif type == 2:
  430. self.type = monster_img.wood
  431. self.line = monster_img.line3
  432. super().__init__(f"采集木头")
  433. elif type == 3:
  434. self.type = monster_img.mine
  435. self.line = monster_img.line4
  436. super().__init__(f"采矿石")
  437. elif type == 4:
  438. self.type = monster_img.iron
  439. self.line = monster_img.line5
  440. super().__init__(f"采集铁矿石")
  441. else:
  442. self.type = None
  443. self.line = None
  444. super().__init__(f"采集None")
  445. if isSimple:
  446. self.line = None
  447. def run(self):
  448. global g_task_lineCheck
  449. if self.type == None:
  450. return True
  451. basic_operate.go_outside()
  452. maxLineNum = 6
  453. if self.isAddStrenghth or g_task_lineCheck:
  454. maxLineNum = 5
  455. else:
  456. maxLineNum = 6
  457. if basic_operate.get_line_num() >= maxLineNum:
  458. return False
  459. if False == basic_operate.click_outside_search():
  460. return False
  461. if waitFindImg_withBool(monster_img.search, 2, 1):
  462. myTimeSleep_big()
  463. yys_dragAuto(monster_img.move_right)
  464. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  465. return False
  466. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  467. return False
  468. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  469. return False
  470. if self.line != None:
  471. waitClickImg_noWait_withBool(self.line, 2, 1)
  472. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  473. return False
  474. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  475. maxTryTimes = 3
  476. while maxTryTimes > 0:
  477. maxTryTimes -= 1
  478. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  479. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  480. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  481. break
  482. return True
  483. class task_train(dongri_task):
  484. def __init__(self, train_type = None):
  485. super().__init__(f"检查训练{train_type}")
  486. self.train_type = train_type
  487. def run(self):
  488. basic_operate.go_town()
  489. if self.train_type == 'None':
  490. return True
  491. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  492. return False
  493. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  494. return False
  495. tryTimes = 3
  496. isSuccess = False
  497. while tryTimes > 0:
  498. tryTimes -= 1
  499. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  500. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  501. isSuccess = True
  502. break
  503. if isSuccess == False:
  504. pcacc_mouse.quickclick_current()
  505. myTimeSleep_big()
  506. pcacc_mouse.quickclick_current()
  507. if waitClickImg_noWait_withBool(train_img.train, 2, 1) == False:
  508. return False
  509. if self.train_type == 'lv1':
  510. myTimeSleep_big()
  511. yys_dragAuto(train_img.move_left)
  512. yys_dragAuto(train_img.move_left)
  513. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  514. elif self.train_type == 'lv8':
  515. waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
  516. elif self.train_type == 'lv9':
  517. waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
  518. elif self.train_type == 'upgrade':
  519. waitClickImg_noWait_withBool(train_img.upgrade_small, 2, 1)
  520. waitClickImg_noWait_withBool(train_img.upgrade_big, 2, 1)
  521. return basic_operate.enter_auto_supply_resource([train_img.begin_train,train_img.begin_train2])
  522. class task_checkHelp(dongri_task):
  523. def __init__(self, isOutSide = False):
  524. super().__init__(f"检查帮助")
  525. self.isOutSide = isOutSide
  526. def run(self):
  527. if self.isOutSide:
  528. basic_operate.go_outside()
  529. else:
  530. basic_operate.go_town()
  531. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  532. return True
  533. class task_gotoTree(dongri_task):
  534. def __init__(self):
  535. super().__init__(f"查看生命之树")
  536. def run(self):
  537. basic_operate.go_town()
  538. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  539. return False
  540. myTimeSleep_big()
  541. yys_dragAuto(check_img.move_down)
  542. yys_dragAuto(check_img.move_down)
  543. myTimeSleep_big()
  544. if waitClickImg_noWait_withBool(check_img.life_tree, 2, 1) == False:
  545. return False
  546. myTimeSleep_big()
  547. pcacc_mouse.quickclick_current()
  548. myTimeSleep_big()
  549. waitClickImg_noWait_withBool(check_img.life_jam, 2, 1)
  550. waitClickImg_noWait_withBool(check_img.life_jam, 2, 1)
  551. return True
  552. class task_checkStoreRoom(dongri_task):
  553. def __init__(self):
  554. super().__init__(f"检查仓库或招募")
  555. def run(self):
  556. basic_operate.go_town()
  557. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  558. return False
  559. myTimeSleep_big()
  560. yys_dragAuto(check_img.move_down)
  561. yys_dragAuto(check_img.move_down)
  562. myTimeSleep_big()
  563. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  564. return False
  565. myTimeSleep_big()
  566. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
  567. waitClickImg_noWait_withBool(check_img.bigGet, 2, 1)
  568. pcacc_mouse.quickclick_current()
  569. myTimeSleep_big()
  570. if waitClickImg_noWait_withBool((check_img.detail,check_img.detail2), 2, 1):
  571. myTimeSleep_big()
  572. basic_operate.go_town()
  573. myTimeSleep_big()
  574. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  575. return False
  576. myTimeSleep_big()
  577. pcacc_mouse.quickclick_current()
  578. myTimeSleep_big()
  579. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  580. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  581. else:
  582. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  583. myTimeSleep_big()
  584. dstPos = get_yys_random_point(check_img.pet_getRegion)
  585. pcacc_mouse.click(dstPos[0], dstPos[1])
  586. myTimeSleep_big()
  587. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  588. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  589. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  590. return True
  591. class task_checkConfilits(dongri_task):
  592. def __init__(self):
  593. super().__init__(f"检查集结")
  594. def run(self):
  595. basic_operate.go_outside()
  596. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  597. return False
  598. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  599. return False
  600. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  601. return False
  602. return True
  603. class task_checkDonata(dongri_task):
  604. def __init__(self):
  605. super().__init__(f"检查捐献")
  606. def run(self):
  607. basic_operate.go_town()
  608. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  609. return False
  610. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  611. return False
  612. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  613. return False
  614. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  615. return False
  616. else:
  617. maxTryTimes = 3
  618. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  619. maxTryTimes -= 1
  620. return True
  621. class task_checkAdventure(dongri_task):
  622. def __init__(self):
  623. super().__init__(f"检查冒险")
  624. def run(self):
  625. basic_operate.go_town()
  626. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  627. return False
  628. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  629. return False
  630. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  631. return False
  632. return True
  633. class task_waitTime(dongri_task):
  634. def __init__(self):
  635. super().__init__(f"等待时间")
  636. def run(self):
  637. myTimeSleep(300)
  638. class check_buildOrResearch(dongri_task):
  639. def __init__(self):
  640. super().__init__(f"检查建筑或研究")
  641. def run(self):
  642. basic_operate.go_town()
  643. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  644. return False
  645. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  646. return False
  647. dstType = 'none'
  648. while True:
  649. 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):
  650. dstType = 'build'
  651. break
  652. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  653. if not handRet:
  654. return False
  655. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  656. dstPos = [0, 0]
  657. if not detailRet:
  658. # 如果找不到详细信息,兵营之类的,需点中间
  659. dstPos = [handPos[0] - 70, handPos[1] + 120]
  660. else:
  661. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  662. tryTimes = 5
  663. while tryTimes > 0:
  664. tryTimes -= 1
  665. myTimeSleep_big()
  666. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  667. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  668. dstType = 'research'
  669. break
  670. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  671. dstType = 'build'
  672. break
  673. break
  674. if dstType == 'none':
  675. print('没有找到建筑或研究')
  676. return False
  677. elif dstType == 'build':
  678. buildtimes = 4
  679. 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]):
  680. buildtimes -= 1
  681. if buildtimes == 0:
  682. break
  683. continue
  684. elif dstType == 'research':
  685. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  686. return False
  687. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  688. return False
  689. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  690. return True
  691. class task_information(dongri_task):
  692. def __init__(self, isAddStrengh = False):
  693. super().__init__(f"检查情报")
  694. self.isAddStrengh = isAddStrengh
  695. def run(self):
  696. basic_operate.go_outside()
  697. if False == waitFindImg_withBool((monster_img.enough_strengh, monster_img.enough_strengh3), 2, 1):
  698. if self.isAddStrengh:
  699. basic_operate.add_strength()
  700. basic_operate.go_outside()
  701. else:
  702. print("没有足够的体力了")
  703. return False
  704. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  705. return False
  706. waitClickImg_noWait_withBool(information_img.information_suc, 1, 1)
  707. hero_arr = [information_img.hero0, information_img.hero1, information_img.hero2, information_img.hero3, information_img.hero4]
  708. camp_arr = [information_img.camp1, information_img.camp2, information_img.camp3, information_img.camp4]
  709. wolf_arr = [information_img.wolf0, information_img.wolf1, information_img.wolf2, information_img.wolf3, information_img.wolf4]
  710. total_arr = hero_arr + camp_arr + wolf_arr
  711. if waitFindImg_withBool(total_arr, 2, 1) == False:
  712. return False
  713. if waitClickImg_noWait_withBool(hero_arr, 0.5, 0.5):
  714. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  715. return False
  716. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  717. return False
  718. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  719. return False
  720. myTimeSleep_big()
  721. return True
  722. elif waitClickImg_noWait_withBool(camp_arr, 0.5, 0.5):
  723. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  724. return False
  725. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  726. return False
  727. return True
  728. elif waitClickImg_noWait_withBool(wolf_arr, 0.5, 0.5):
  729. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  730. return False
  731. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  732. return False
  733. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  734. return False
  735. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  736. return False
  737. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  738. maxTryTimes = 3
  739. while maxTryTimes > 0:
  740. maxTryTimes -= 1
  741. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  742. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  743. break
  744. return True
  745. else:
  746. return False
  747. class task_returnAllLine(dongri_task):
  748. def __init__(self):
  749. super().__init__(f"返回所有路线")
  750. def run(self):
  751. basic_operate.go_outside()
  752. maxTryTimes = 6
  753. while maxTryTimes > 0:
  754. maxTryTimes -= 1
  755. if basic_operate.return_line() == False:
  756. break
  757. return True
  758. class task_paticipateInTeam(dongri_task):
  759. def __init__(self):
  760. typeArr = [1,4]
  761. type = typeArr[random.randint(0, len(typeArr) - 1)]
  762. if type == 1:
  763. self.line = monster_img.line1
  764. elif type == 4:
  765. self.line = monster_img.line4
  766. super().__init__(f"参与队伍{type}")
  767. def run(self):
  768. basic_operate.go_outside()
  769. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  770. return False
  771. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1, True) == False:
  772. yys_dragAuto(check_img.move_down)
  773. myTimeSleep_big()
  774. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1, True) == False:
  775. return False
  776. waitClickImg_noWait_withBool(self.line, 0.1, 1)
  777. maxTryTimes = 3
  778. while maxTryTimes > 0:
  779. maxTryTimes -= 1
  780. waitClickImg_withBool([monster_img.fight, monster_img.fight2, monster_img.fight3], 1, 0.5)
  781. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 0.5):
  782. break
  783. return True
  784. class task_cure(dongri_task):
  785. def __init__(self, continueCure = False, cureNum = None):
  786. cureStr = ""
  787. if continueCure:
  788. cureStr = f"连续"
  789. super().__init__(f"{cureStr}治疗{cureNum}")
  790. self.continueCure = continueCure
  791. self.cureNum = cureNum
  792. def run(self):
  793. basic_operate.go_town()
  794. basic_operate.go_outside()
  795. if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  796. return False
  797. while waitFindImg_withBool(special_activity_img.done_immediately, 1, 0.5) == False:
  798. if waitClickImg_noWait_withBool(special_activity_img.quick_choose, 1, 0.5) == False:
  799. return False
  800. while waitFindImg_withBool(special_activity_img.done_immediately, 1, 0.5):
  801. if waitClickImg_noWait_withBool(special_activity_img.choose_zero, 1, 0.5) == False:
  802. return False
  803. else:
  804. myTimeSleep_big()
  805. pcacc_mouse.input_string(str(self.cureNum))
  806. if self.continueCure == False:
  807. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  808. return False
  809. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  810. return False
  811. else:
  812. maxCureSoilder = 30000
  813. maxTryTimes = int(maxCureSoilder) // int(self.cureNum) * 2
  814. while waitClickImg_noWait_withBool((check_img.cure, check_img.help4, check_img.help5), 30, 0.2) and maxTryTimes >= 0:
  815. maxTryTimes -= 1
  816. continue
  817. waitClickImg_noWait_withBool((check_img.help4, check_img.help5), 1, 1)
  818. return True
  819. class task_useAnnimalSkill(dongri_task):
  820. def __init__(self):
  821. super().__init__(f"使用动物技能")
  822. def run(self):
  823. basic_operate.go_outside()
  824. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  825. return False
  826. if waitClickImg_noWait_withBool((check_img.wolf_skill, check_img.elephant_skill, check_img.lu_skill), 2, 1) == False:
  827. return False
  828. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  829. return False
  830. class task_activity_lianmeng(dongri_task):
  831. def __init__(self):
  832. super().__init__(f"联盟总动员")
  833. def run(self):
  834. basic_operate.go_town()
  835. myTimeSleep_big()
  836. if waitClickImg_noWait_withBool(special_activity_img.normal, 1, 0.5) == False:
  837. return False
  838. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2,special_activity_img.lianmeng3), 1, 0.5) == False:
  839. yys_dragAuto(special_activity_img.move_left)
  840. myTimeSleep_small()
  841. yys_dragAuto(special_activity_img.move_left)
  842. myTimeSleep_small()
  843. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2, special_activity_img.lianmeng3), 1, 0.5) == False:
  844. return False
  845. waitClickImg_noWait_withBool(special_activity_img.task_done, 1, 0.5)
  846. if waitFindImg_withBool(special_activity_img.doing_task, 1, 0.5) == False:
  847. down_tryTimes = 3
  848. while down_tryTimes > 0:
  849. down_tryTimes -= 1
  850. if waitClickImg_noWait_withBool((special_activity_img.shili_120_2, special_activity_img.shili_860_2, special_activity_img.shili_430), 1, 0.5, True) == True:
  851. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  852. return False
  853. break
  854. elif waitFindImg_withBool(special_activity_img.shili_2, 1, 0.5) == True:
  855. save_game_screen()
  856. yys_dragAuto(special_activity_img.move_down)
  857. up_tryTimes = 5
  858. while up_tryTimes > 0:
  859. up_tryTimes -= 1
  860. myTimeSleep_small()
  861. yys_dragAuto(change_direction(special_activity_img.move_down))
  862. if waitFindImg_withBool((special_activity_img.shili_120, special_activity_img.shili_860_2), 2, 1, True) == False:
  863. maxTryTimes = 2
  864. while waitClickImg_noWait_withBool((special_activity_img.owning2), 2, 1) == True:
  865. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  866. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  867. maxTryTimes -= 1
  868. if maxTryTimes <= 0:
  869. break
  870. return True
  871. class task_checkMaster(dongri_task):
  872. def __init__(self):
  873. super().__init__(f"检查统帅")
  874. def run(self):
  875. basic_operate.go_town()
  876. if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
  877. return False
  878. if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
  879. return False
  880. myTimeSleep_big()
  881. pcacc_mouse.quickclick_current()
  882. if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
  883. return False
  884. return True
  885. class task_checkActivities(dongri_task):
  886. def __init__(self):
  887. super().__init__(f"检查各种活动时间")
  888. def find_all_matching_events(self, parts, input_word):
  889. results = []
  890. # 查找所有包含输入关键词的项
  891. matches = [i for i, part in enumerate(parts) if input_word in part]
  892. for match_index in matches:
  893. # 从匹配项开始向后查找第一个时间或状态
  894. for i in range(match_index + 1, len(parts)):
  895. current_part = parts[i]
  896. # 检查是否是时间(如 19:30)或状态(如 已结束)
  897. if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
  898. dst = {"item":parts[match_index], "time":current_part}
  899. results.append(dst)
  900. break # 找到第一个匹配就停止
  901. return results
  902. def run(self):
  903. global todo_msg, todo_list
  904. basic_operate.go_outside()
  905. if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
  906. return False
  907. if waitFindImg_withBool(check_img.todoList, 2, 1) == False:
  908. return False
  909. if waitFindImg_withBool(special_activity_img.beijing_time, 1, 0) == True:
  910. waitClickImg_noWait_withBool(special_activity_img.task_refresh, 1, 0)
  911. activityStr = yys_ocrAuto(check_img.todo_region)
  912. if activityStr:
  913. todo_msg = activityStr
  914. print(todo_msg)
  915. result = []
  916. judianArr = self.find_all_matching_events(activityStr, "据点")
  917. #result.extend(judianArr)
  918. baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
  919. #result.extend(baoleiArr)
  920. juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
  921. result.extend(juxiongArr)
  922. yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
  923. #result.extend(yaosaiArr)
  924. todo_list = result
  925. print(todo_list)
  926. print(get_todo_time("巨熊行动"))
  927. return activityStr
  928. class task_visit_island(dongri_task):
  929. def __init__(self):
  930. super().__init__(f"访问岛屿")
  931. def run(self):
  932. basic_operate.go_outside()
  933. if waitClickImg_noWait_withBool(check_img.visit_island_small, 2, 1) == False:
  934. return False
  935. if waitClickImg_noWait_withBool(check_img.visit_enter, 2, 1) == False:
  936. return False
  937. if waitClickImg_noWait_withBool(check_img.visit_island_big, 2, 1) == False:
  938. return False
  939. return True
  940. class task_fight_ranshuang(dongri_task):
  941. def __init__(self):
  942. super().__init__(f"打燃霜")
  943. def run(self):
  944. basic_operate.backToGame()
  945. while True:
  946. if waitClickImg_noWait_withBool(monster_img.ranshuang_search, 0.5, 0.5) == False:
  947. return False
  948. if waitClickImg_noWait_withBool(monster_img.ranshuang_attack, 0.5, 0.5) == False:
  949. firstPos = get_yys_random_point(special_activity_img.mid_enemy_region)
  950. pcacc_mouse.click(firstPos[0], firstPos[1])
  951. myTimeSleep_big()
  952. if waitClickImg_noWait_withBool(monster_img.ranshuang_attack, 1, 0.5) == False:
  953. break
  954. break
  955. if waitClickImg_noWait_withBool([monster_img.fight, monster_img.fight2], 1, 0.5) == False:
  956. return False
  957. return True
  958. class task_fight_enemy(dongri_task):
  959. def __init__(self):
  960. super().__init__(f"打敌人or王城")
  961. def run(self):
  962. basic_operate.go_town()
  963. basic_operate.go_outside()
  964. if waitClickImg_noWait_withBool(special_activity_img.collection, 2, 1) == False:
  965. return False
  966. if waitClickImg_noWait_withBool(special_activity_img.enemy, 2, 1) == False:
  967. return False
  968. attackArr = [monster_img.attack, monster_img.attack2, monster_img.ranshuang_attack, monster_img.outside_attack, monster_img.defend]
  969. myTimeSleep_big()
  970. firstPos = get_yys_random_point(special_activity_img.first_enemy_region)
  971. pcacc_mouse.click(firstPos[0], firstPos[1])
  972. maxTryTimes = 5
  973. if waitFindImg_withBool(special_activity_img.visit_island, 1, 1) == True:
  974. return False
  975. while waitFindImg_withBool(attackArr, 1, 0) == False and maxTryTimes > 0:
  976. if waitClickImg_noWait_withBool(special_activity_img.outside_soilder, 1, 1) == True:
  977. break
  978. #if waitFindImg_withBool(special_activity_img.outside_pcacc, 1, 1) == True:
  979. # break
  980. #else:
  981. # return False
  982. maxTryTimes -= 1
  983. myTimeSleep_big()
  984. mid_enemy_pos = get_yys_random_point(special_activity_img.mid_enemy_region)
  985. pcacc_mouse.click(mid_enemy_pos[0], mid_enemy_pos[1])
  986. myTimeSleep_big()
  987. if waitFindImg_withBool(special_activity_img.visit_island, 1, 1) == True:
  988. return False
  989. if waitClickImg_noWait_withBool(attackArr, 1, 0) == False:
  990. return False
  991. waitClickImg_noWait_withBool(monster_img.team_go, 2, 1)#派遣队伍
  992. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  993. return False
  994. if waitClickImg_noWait_withBool([monster_img.fight, monster_img.fight2], 2, 1) == False:
  995. return False
  996. return True
  997. class task_get_redPackage(dongri_task):
  998. def __init__(self):
  999. super().__init__(f"领取红包")
  1000. def run(self):
  1001. basic_operate.go_outside()
  1002. if waitClickImg_noWait_withBool((check_img.talk_in,check_img.talk_in2, check_img.talk_in3), 2, 1) == False:
  1003. return False
  1004. waitClickImg_noWait_withBool(check_img.talkin_person, 2, 1)
  1005. oldTime = time.time()
  1006. while True:
  1007. if time.time() - oldTime > 150:
  1008. break
  1009. waitClickImg_noWait_withBool((special_activity_img.red_package, special_activity_img.red_package2, special_activity_img.msg_new, special_activity_img.red_package_open), 2, 0)
  1010. return True
  1011. class task_read_mails(dongri_task):
  1012. def __init__(self):
  1013. super().__init__(f"读邮件")
  1014. def run(self):
  1015. basic_operate.go_town()
  1016. if waitClickImg_noWait_withBool(check_img.mail_btn, 2, 1) == False:
  1017. return False
  1018. waitClickImg_noWait_withBool(check_img.mail_collect, 2, 1)
  1019. if waitClickImg_noWait_withBool(check_img.mail_union, 2, 1) == False:
  1020. return False
  1021. if waitClickImg_noWait_withBool(check_img.mail_read, 2, 1) == False:
  1022. return False
  1023. if waitClickImg_noWait_withBool(check_img.mail_system, 2, 1) == False:
  1024. return False
  1025. if waitClickImg_noWait_withBool(check_img.mail_read, 2, 1) == False:
  1026. return False
  1027. if waitClickImg_noWait_withBool(check_img.mail_reports, 2, 1) == False:
  1028. return False
  1029. if waitClickImg_noWait_withBool(check_img.mail_read, 2, 1) == False:
  1030. return False
  1031. return True
  1032. class task_checkBenifitStatus(dongri_task):
  1033. def __init__(self):
  1034. super().__init__(f"查看增益状态")
  1035. def run(self):
  1036. basic_operate.go_town()
  1037. if waitFindImg_withBool(check_img.benefit_collect, 2, 1) == True:
  1038. return True
  1039. if waitClickImg_noWait_withBool(check_img.add_benefit, 2, 1) == False:
  1040. return False
  1041. waitClickImg_noWait_withBool(check_img.benefit_evolve, 2, 1)
  1042. if waitClickImg_noWait_withBool(check_img.benefit_collect_info, 2, 1) == False:
  1043. return False
  1044. myTimeSleep_big()
  1045. dstPos = get_yys_random_point(check_img.benefit_use_region)
  1046. pcacc_mouse.click(dstPos[0], dstPos[1])
  1047. myTimeSleep_big()
  1048. if waitClickImg_noWait_withBool(check_img.benefit_buy, 2, 1) == False:
  1049. return False
  1050. waitClickImg_noWait_withBool(check_img.buy_enter, 2, 1)
  1051. return True
  1052. class task_checkDiamond(dongri_task):
  1053. def __init__(self):
  1054. super().__init__(f"查看钻石活动")
  1055. def run(self):
  1056. basic_operate.go_town()
  1057. if waitClickImg_noWait_withBool(check_img.worthy_activity, 2, 1) == False:
  1058. return False
  1059. myTimeSleep_big()
  1060. yys_dragAuto(change_direction(special_activity_img.move_left))
  1061. myTimeSleep_big()
  1062. yys_dragAuto(change_direction(special_activity_img.move_left))
  1063. waitClickImg_noWait_withBool(check_img.diamond_activity, 2, 1)
  1064. waitClickImg_noWait_withBool(check_img.gain_diamond, 2, 1)
  1065. dstPos = get_yys_random_point(check_img.diamond_save)
  1066. pcacc_mouse.click(dstPos[0], dstPos[1])
  1067. myTimeSleep_big()
  1068. dstPos = get_yys_random_point(check_img.diamond_saveMax)
  1069. pcacc_mouse.click(dstPos[0], dstPos[1])
  1070. myTimeSleep_big()
  1071. if waitClickImg_noWait_withBool(check_img.diamond_save_btn, 2, 1) == False:
  1072. return False
  1073. return True
  1074. class task_fight_campion(dongri_task):
  1075. def __init__(self):
  1076. super().__init__(f"打竞技场")
  1077. def run(self):
  1078. basic_operate.go_town()
  1079. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  1080. return False
  1081. myTimeSleep_big()
  1082. if waitClickImg_noWait_withBool(special_activity_img.goto_arrow, 2, 1) == False:
  1083. return False
  1084. myTimeSleep_big()
  1085. maxMoveTimes = 2
  1086. while maxMoveTimes > 0:
  1087. maxMoveTimes -= 1
  1088. yys_dragAuto(special_activity_img.champion_move)
  1089. myTimeSleep_big()
  1090. if waitClickImg_noWait_withBool(special_activity_img.enter_champion, 2, 1) == True:
  1091. break
  1092. if waitClickImg_noWait_withBool(special_activity_img.champion_fight, 2, 1) == False:
  1093. return False
  1094. myTimeSleep_big()
  1095. dstPos = get_yys_random_point(special_activity_img.fight_last)
  1096. pcacc_mouse.click(dstPos[0], dstPos[1])
  1097. myTimeSleep_big()
  1098. if waitClickImg_noWait_withBool(special_activity_img.champion_fight2, 2, 1) == False:
  1099. return False
  1100. return True
  1101. class check_safe_collect(dongri_task):
  1102. def __init__(self):
  1103. super().__init__(f"检查安全收集")
  1104. def run(self):
  1105. basic_operate.go_outside()
  1106. if waitClickImg_noWait_withBool(special_activity_img.collection, 2, 1) == False:
  1107. return False
  1108. if waitClickImg_noWait_withBool(special_activity_img.collection_friend, 2, 1) == False:
  1109. return False
  1110. myTimeSleep_big()
  1111. firstPos = get_yys_random_point(special_activity_img.first_enemy_region)
  1112. pcacc_mouse.click(firstPos[0], firstPos[1])
  1113. maxTryTimes = 2
  1114. while waitClickImg_noWait_withBool(monster_img.collect, 1, 1) == False and maxTryTimes > 0:
  1115. maxTryTimes -= 1
  1116. myTimeSleep_big()
  1117. mid_enemy_pos = get_yys_random_point(special_activity_img.mid_enemy_region)
  1118. pcacc_mouse.click(mid_enemy_pos[0], mid_enemy_pos[1]-40)
  1119. myTimeSleep_big()
  1120. if waitClickImg_noWait_withBool(special_activity_img.big_collect, 2, 1) == False:
  1121. return False
  1122. if waitClickImg_noWait_withBool(monster_img.line7, 2, 1) == False:
  1123. return False
  1124. maxTryTimes = 3
  1125. while maxTryTimes > 0:
  1126. maxTryTimes -= 1
  1127. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  1128. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  1129. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  1130. break
  1131. return True
  1132. if __name__ == '__main__':
  1133. print(get_todo_time("巨熊行动"))
  1134. #save_game_screen()
  1135. #basic_operate.get_line_num()
  1136. #task_cure(True, 85).run()
  1137. #task_fight_enemy().run()
  1138. #task_fight_ranshuang().run()
  1139. #task_gotoTree().run()
  1140. #task_fight_jina_only().run()
  1141. #task_checkConfilits().run()
  1142. task_checkActivities().run()
  1143. #task_checkMaster().run()
  1144. #basic_operate.get_line_num()
  1145. #yys_ocrAuto(check_img.line_orc)
  1146. #basic_operate.go_town()
  1147. #basic_operate.add_strength()
  1148. #task_fightMonster(False, False,False).run()
  1149. #task_checkHelp().run()
  1150. #task_checkStoreRoom().run()
  1151. #task_start_game(0)
  1152. #check_safe_collect().run()
  1153. #task_fight_campion().run()
  1154. #task_activity_lianmeng().run()
  1155. #task_fight_yongbing(True).run()
  1156. #task_collect([4,3,2,1]).run()
  1157. #task_train("upgrade").run()
  1158. #task_information(True).run()
  1159. #check_buildOrResearch().run()
  1160. #task_checkDonata().run()
  1161. #task_collect(1).run()
  1162. #task_collect(2).run()
  1163. #task_collect(3).run()
  1164. #task_collect(4).run()
  1165. #task_returnAllLine().run()
  1166. #task_paticipateInTeam().run()
  1167. #task_fight_jina(True).run()
  1168. #task_get_redPackage().run()
  1169. #task_read_mails().run()
  1170. #task_checkBenifitStatus().run()
  1171. #task_checkDiamond().run()