dongri_task.py 60 KB

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