dongri_task.py 62 KB

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