dongri_task.py 59 KB

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