dongri_task.py 62 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733
  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 or type(target_time_str) is not str:
  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(21, 00))
  390. end_time = datetime.combine(now.date(), dt.time(22, 00))
  391. # 判断当前时间是否超过20:30
  392. if now > target_time and now < end_time:
  393. print("当前时间已超过20:30,不执行操作")
  394. return False
  395. basic_operate.go_outside()
  396. if False == waitFindImg_withBool((monster_img.enough_strengh2, monster_img.enough_strengh3), 2, 1):
  397. if self.add_strengh:
  398. basic_operate.add_strength()
  399. basic_operate.go_outside()
  400. else:
  401. print("没有足够的体力了")
  402. return False
  403. maxLineNum = 6
  404. if basic_operate.get_line_num() >= maxLineNum:
  405. return False
  406. if False == basic_operate.click_outside_search():
  407. return False
  408. if waitFindImg_withBool(monster_img.search, 2, 1):
  409. myTimeSleep_big()
  410. yys_dragAuto(monster_img.move_left)
  411. if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
  412. return False
  413. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  414. return False
  415. if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
  416. return False
  417. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  418. if not self.isSimple:
  419. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  420. return False
  421. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  422. return False
  423. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  424. return False
  425. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  426. maxTryTimes = 3
  427. while maxTryTimes > 0:
  428. maxTryTimes -= 1
  429. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  430. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  431. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  432. break
  433. return True
  434. class task_collect(dongri_task):
  435. def __init__(self, type = 0, isSimple = False, isAddStrenghth = False):
  436. self.isSimple = isSimple
  437. self.isAddStrenghth = isAddStrenghth
  438. if isinstance(type, (list, tuple)):
  439. typeArr = type
  440. type = typeArr[random.randint(0, len(typeArr) - 1)]
  441. elif type == 0:
  442. typeArr = [4,3,2,1]
  443. type = typeArr[random.randint(0, len(typeArr) - 1)]
  444. elif type == 5:
  445. typeArr = [2,1]
  446. type = typeArr[random.randint(0, len(typeArr) - 1)]
  447. if type == 1:
  448. self.type = monster_img.meat
  449. self.line = monster_img.line2
  450. super().__init__(f"采集肉")
  451. elif type == 2:
  452. self.type = monster_img.wood
  453. self.line = monster_img.line3
  454. super().__init__(f"采集木头")
  455. elif type == 3:
  456. self.type = monster_img.mine
  457. self.line = monster_img.line4
  458. super().__init__(f"采矿石")
  459. elif type == 4:
  460. self.type = monster_img.iron
  461. self.line = monster_img.line5
  462. super().__init__(f"采集铁矿石")
  463. else:
  464. self.type = None
  465. self.line = None
  466. super().__init__(f"采集None")
  467. if isSimple:
  468. self.line = None
  469. def run(self):
  470. global g_task_lineCheck
  471. if self.type == None:
  472. return True
  473. basic_operate.go_outside()
  474. maxLineNum = 6
  475. if self.isAddStrenghth or g_task_lineCheck:
  476. maxLineNum = 5
  477. else:
  478. maxLineNum = 6
  479. if basic_operate.get_line_num() >= maxLineNum:
  480. return False
  481. if False == basic_operate.click_outside_search():
  482. return False
  483. if waitFindImg_withBool(monster_img.search, 2, 1):
  484. myTimeSleep_big()
  485. yys_dragAuto(monster_img.move_right)
  486. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  487. return False
  488. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  489. return False
  490. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  491. return False
  492. if self.line != None:
  493. waitClickImg_noWait_withBool(self.line, 2, 1)
  494. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  495. maxTryTimes = 3
  496. while maxTryTimes > 0:
  497. maxTryTimes -= 1
  498. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  499. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  500. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  501. break
  502. return True
  503. class task_train(dongri_task):
  504. def __init__(self, train_type = None):
  505. super().__init__(f"检查训练{train_type}")
  506. self.train_type = train_type
  507. def run(self):
  508. basic_operate.go_town()
  509. if self.train_type == 'None':
  510. return True
  511. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  512. return False
  513. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  514. return False
  515. tryTimes = 3
  516. isSuccess = False
  517. while tryTimes > 0:
  518. tryTimes -= 1
  519. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  520. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  521. isSuccess = True
  522. break
  523. if isSuccess == False:
  524. pcacc_mouse.quickclick_current()
  525. myTimeSleep_big()
  526. pcacc_mouse.quickclick_current()
  527. if waitClickImg_noWait_withBool(train_img.train, 2, 1) == False:
  528. return False
  529. if self.train_type == 'lv1':
  530. myTimeSleep_big()
  531. yys_dragAuto(train_img.move_left)
  532. yys_dragAuto(train_img.move_left)
  533. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  534. elif self.train_type == 'lv8':
  535. waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
  536. elif self.train_type == 'lv9':
  537. waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
  538. elif self.train_type == 'upgrade':
  539. waitClickImg_noWait_withBool(train_img.upgrade_small, 2, 1)
  540. waitClickImg_noWait_withBool(train_img.upgrade_big, 2, 1)
  541. return basic_operate.enter_auto_supply_resource([train_img.begin_train,train_img.begin_train2])
  542. class task_checkHelp(dongri_task):
  543. def __init__(self, isOutSide = False):
  544. super().__init__(f"检查帮助")
  545. self.isOutSide = isOutSide
  546. def run(self):
  547. if self.isOutSide:
  548. basic_operate.go_outside()
  549. else:
  550. basic_operate.go_town()
  551. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  552. return True
  553. class task_gotoTree(dongri_task):
  554. def __init__(self):
  555. super().__init__(f"查看生命之树")
  556. def run(self):
  557. basic_operate.go_town()
  558. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  559. return False
  560. myTimeSleep_big()
  561. yys_dragAuto(check_img.move_down)
  562. yys_dragAuto(check_img.move_down)
  563. myTimeSleep_big()
  564. if waitClickImg_noWait_withBool(check_img.life_tree, 2, 1) == False:
  565. return False
  566. myTimeSleep_big()
  567. pcacc_mouse.quickclick_current()
  568. myTimeSleep_big()
  569. waitClickImg_noWait_withBool((check_img.life_jam, check_img.life_jam2), 2, 1)
  570. waitClickImg_noWait_withBool((check_img.life_jam, check_img.life_jam2), 2, 1)
  571. return True
  572. class task_getStrength(dongri_task):
  573. def __init__(self):
  574. super().__init__(f"获取体力")
  575. def run(self):
  576. basic_operate.go_town()
  577. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  578. return False
  579. if waitClickImg_noWait_withBool(check_img.pannel_research, 2, 1) == False:
  580. return False
  581. myTimeSleep_big()
  582. yys_dragAuto(change_direction(special_activity_img.champion_move))
  583. myTimeSleep_big()
  584. if waitClickImg_noWait_withBool(check_img.store_strength, 3, 1):
  585. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  586. return True
  587. class task_checkStoreRoom(dongri_task):
  588. def __init__(self):
  589. super().__init__(f"检查仓库或招募")
  590. def run(self):
  591. basic_operate.go_town()
  592. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  593. return False
  594. myTimeSleep_big()
  595. yys_dragAuto(check_img.move_down)
  596. yys_dragAuto(check_img.move_down)
  597. myTimeSleep_big()
  598. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  599. return False
  600. myTimeSleep_big()
  601. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:# storeroom
  602. waitClickImg_noWait_withBool((check_img.bigGet, check_img.chenxi_get2), 2, 1)
  603. pcacc_mouse.quickclick_current()
  604. myTimeSleep_big()
  605. if waitClickImg_noWait_withBool((check_img.detail,check_img.detail2), 2, 1):
  606. myTimeSleep_big()
  607. basic_operate.go_town()
  608. myTimeSleep_big()
  609. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  610. return False
  611. myTimeSleep_big()
  612. pcacc_mouse.quickclick_current()
  613. myTimeSleep_big()
  614. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  615. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  616. else:
  617. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  618. myTimeSleep_big()
  619. dstPos = get_yys_random_point(check_img.pet_getRegion)
  620. pcacc_mouse.click(dstPos[0], dstPos[1])
  621. myTimeSleep_big()
  622. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  623. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  624. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  625. return True
  626. class task_checkConfilits(dongri_task):
  627. def __init__(self):
  628. super().__init__(f"检查集结")
  629. def run(self):
  630. basic_operate.go_outside()
  631. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  632. return False
  633. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  634. return False
  635. if waitFindImg_withBool(check_img.conflict_50, 2, 1) == True:
  636. waitClickImg_noWait_withBool(check_img.conflict_stop, 2, 1)
  637. return True
  638. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  639. return False
  640. return True
  641. class task_checkDonata(dongri_task):
  642. def __init__(self):
  643. super().__init__(f"检查捐献")
  644. def run(self):
  645. basic_operate.go_town()
  646. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  647. return False
  648. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  649. return False
  650. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  651. return False
  652. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  653. return False
  654. else:
  655. maxTryTimes = 3
  656. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  657. maxTryTimes -= 1
  658. return True
  659. class task_checkUnionTreasure(dongri_task):
  660. def __init__(self):
  661. super().__init__(f"检查联盟宝藏")
  662. def run(self):
  663. basic_operate.go_town()
  664. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  665. return False
  666. if waitClickImg_noWait_withBool(check_img.union_treasure, 2, 1) == False:
  667. return False
  668. waitClickImg_noWait_withBool(check_img.union_gift, 2, 1)
  669. while waitClickImg_noWait_withBool((check_img.union_get), 2, 0) == True:
  670. continue
  671. waitClickImg_noWait_withBool(check_img.union_gain, 2, 1)
  672. while waitClickImg_noWait_withBool((check_img.union_get), 2, 0) == True:
  673. continue
  674. waitClickImg_noWait_withBool(check_img.union_bigtreasure, 2, 1)
  675. return True
  676. class task_checkAdventure(dongri_task):
  677. def __init__(self):
  678. super().__init__(f"检查冒险")
  679. def run(self):
  680. basic_operate.go_town()
  681. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  682. return False
  683. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  684. return False
  685. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  686. return False
  687. return True
  688. class task_waitTime(dongri_task):
  689. def __init__(self):
  690. super().__init__(f"等待时间")
  691. def run(self):
  692. myTimeSleep(300)
  693. class task_check_Research(dongri_task):
  694. def __init__(self):
  695. super().__init__(f"检查研究")
  696. def run(self):
  697. basic_operate.go_town()
  698. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  699. return False
  700. if waitClickImg_noWait_withBool(check_img.pannel_research, 2, 1) == False:
  701. return False
  702. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  703. if not handRet:
  704. return False
  705. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  706. dstPos = [0, 0]
  707. if not detailRet:
  708. # 如果找不到详细信息,兵营之类的,需点中间
  709. dstPos = [handPos[0] - 70, handPos[1] + 120]
  710. else:
  711. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  712. tryTimes = 3
  713. while tryTimes > 0:
  714. tryTimes -= 1
  715. myTimeSleep_big()
  716. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  717. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  718. break
  719. if waitFindImg_withBool(check_img.research_speedup, 2, 1) == True:
  720. return False
  721. 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:
  722. return False
  723. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  724. return False
  725. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  726. class check_buildOrResearch(dongri_task):
  727. def __init__(self):
  728. super().__init__(f"检查建筑或研究")
  729. def run(self):
  730. basic_operate.go_town()
  731. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  732. return False
  733. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  734. return False
  735. dstType = 'none'
  736. while True:
  737. 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):
  738. dstType = 'build'
  739. break
  740. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  741. if not handRet:
  742. return False
  743. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  744. dstPos = [0, 0]
  745. if not detailRet:
  746. # 如果找不到详细信息,兵营之类的,需点中间
  747. dstPos = [handPos[0] - 70, handPos[1] + 120]
  748. else:
  749. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  750. tryTimes = 5
  751. while tryTimes > 0:
  752. tryTimes -= 1
  753. myTimeSleep_big()
  754. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  755. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  756. dstType = 'research'
  757. break
  758. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  759. dstType = 'build'
  760. break
  761. break
  762. if dstType == 'none':
  763. print('没有找到建筑或研究')
  764. return False
  765. elif dstType == 'build':
  766. buildtimes = 4
  767. 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]):
  768. buildtimes -= 1
  769. if buildtimes == 0:
  770. break
  771. continue
  772. elif dstType == 'research':
  773. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  774. return False
  775. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  776. return False
  777. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  778. return True
  779. class task_information(dongri_task):
  780. def __init__(self, isAddStrengh = False):
  781. super().__init__(f"检查情报")
  782. self.isAddStrengh = isAddStrengh
  783. def run(self):
  784. basic_operate.go_outside()
  785. '''
  786. if False == waitFindImg_withBool((monster_img.enough_strengh, monster_img.enough_strengh3), 2, 1):
  787. if self.isAddStrengh:
  788. basic_operate.add_strength()
  789. basic_operate.go_outside()
  790. else:
  791. print("没有足够的体力了")
  792. return False
  793. '''
  794. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  795. return False
  796. waitClickImg_noWait_withBool(information_img.information_suc, 1, 1)
  797. hero_arr = [information_img.hero0, information_img.hero1, information_img.hero2, information_img.hero3, information_img.hero4]
  798. camp_arr = [information_img.camp1, information_img.camp2, information_img.camp3, information_img.camp4]
  799. wolf_arr = [information_img.wolf0, information_img.wolf1, information_img.wolf2, information_img.wolf3, information_img.wolf4, information_img.huojing1]
  800. total_arr = hero_arr + camp_arr + wolf_arr
  801. if waitFindImg_withBool(total_arr, 2, 1) == False:
  802. return False
  803. if waitClickImg_noWait_withBool(hero_arr, 0.5, 0.5):
  804. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  805. return False
  806. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  807. return False
  808. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  809. return False
  810. myTimeSleep_big()
  811. return True
  812. elif waitClickImg_noWait_withBool(camp_arr, 0.5, 0.5):
  813. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  814. return False
  815. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  816. return False
  817. return True
  818. elif waitClickImg_noWait_withBool(wolf_arr, 0.5, 0.5):
  819. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  820. return False
  821. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  822. return False
  823. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  824. return False
  825. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  826. return False
  827. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  828. maxTryTimes = 3
  829. while maxTryTimes > 0:
  830. maxTryTimes -= 1
  831. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  832. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  833. break
  834. return True
  835. else:
  836. return False
  837. class task_returnAllLine(dongri_task):
  838. def __init__(self):
  839. super().__init__(f"返回所有路线")
  840. def run(self):
  841. basic_operate.go_town()
  842. basic_operate.go_outside()
  843. maxTryTimes = 6
  844. while maxTryTimes > 0:
  845. maxTryTimes -= 1
  846. if basic_operate.return_line() == False:
  847. break
  848. return True
  849. class task_paticipateInTeam2(dongri_task):
  850. def __init__(self, checkPower=True):
  851. typeArr = [1,3,4]
  852. type = typeArr[random.randint(0, len(typeArr) - 1)]
  853. if type == 1:
  854. self.line = monster_img.line1
  855. elif type == 2:
  856. self.line = monster_img.line2
  857. elif type == 3:
  858. self.line = monster_img.line3
  859. elif type == 4:
  860. self.line = monster_img.line4
  861. self.checkPower = checkPower
  862. hint = "&检查实力"
  863. if checkPower == False:
  864. hint = "&不检查"
  865. super().__init__(f"union队伍{type}{hint}")
  866. def run(self):
  867. basic_operate.go_outside()
  868. if waitClickImg_noWait_withBool((check_img.talk_in,check_img.talk_in2, check_img.talk_in3), 2, 1) == False:
  869. return False
  870. waitClickImg_noWait_withBool(check_img.talkin_union, 1, 0)
  871. if waitClickImg_noWait_withBool(check_img.bear_team, 1, 1, True) == False:
  872. return False
  873. if waitClickImg_noWait_withBool(check_img.bear_add, 1, 1) == False:
  874. return False
  875. waitClickImg_noWait_withBool(self.line, 0.1, 1)
  876. if waitFindImg_withBool(special_activity_img.power0, 0.1, 0) == False:# 实力不为0
  877. if self.checkPower:
  878. if waitFindImg_withBool(check_img.enough_soilder, 1, 0) == False:
  879. return False
  880. waitClickImg_withBool([monster_img.fight, monster_img.fight2, monster_img.fight3], 1, 0)
  881. return True
  882. return False
  883. class task_paticipateInTeam(dongri_task):
  884. def __init__(self, checkPower=True):
  885. typeArr = [1,3,4]
  886. type = typeArr[random.randint(0, len(typeArr) - 1)]
  887. if type == 1:
  888. self.line = monster_img.line1
  889. elif type == 2:
  890. self.line = monster_img.line2
  891. elif type == 3:
  892. self.line = monster_img.line3
  893. elif type == 4:
  894. self.line = monster_img.line4
  895. self.checkPower = checkPower
  896. hint = "&检查实力"
  897. if checkPower == False:
  898. hint = "&不检查"
  899. super().__init__(f"参与队伍{type}{hint}")
  900. def run(self):
  901. basic_operate.go_outside()
  902. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  903. return False
  904. myTimeSleep_big()
  905. dragTimes = 5
  906. for i in range(dragTimes):
  907. yys_dragAuto(check_img.move_down_big)
  908. myTimeSleep_small()
  909. ret = False
  910. for i in range(dragTimes*2):
  911. ret = waitClickImg_noWait_withBool(monster_img.participate, 1, 0, True)
  912. if ret == True:
  913. waitClickImg_noWait_withBool(self.line, 0.1, 1)
  914. if waitFindImg_withBool(special_activity_img.power0, 0.1, 0) == False:# 实力不为0
  915. if self.checkPower:
  916. if waitFindImg_withBool(check_img.enough_soilder, 1, 0) == False:
  917. return False
  918. waitClickImg_withBool([monster_img.fight, monster_img.fight2, monster_img.fight3], 1, 0)
  919. if waitFindImg_withBool(check_img.auto_confilit, 2, 0) == False:
  920. return False
  921. else:
  922. yys_dragAuto(check_img.move_down_big)
  923. myTimeSleep_small()
  924. return True
  925. class task_cure(dongri_task):
  926. def __init__(self, continueCure = False, cureNum = None):
  927. cureStr = ""
  928. if continueCure:
  929. cureStr = f"连续"
  930. super().__init__(f"{cureStr}治疗{cureNum}")
  931. self.continueCure = continueCure
  932. self.cureNum = cureNum
  933. def run(self):
  934. basic_operate.go_town()
  935. basic_operate.go_outside()
  936. if waitClickImg_noWait_withBool([check_img.already_cure,check_img.cure_help], 2, 1) == True:
  937. if waitClickImg_noWait_withBool(check_img.cancel_cure, 2, 1) == False:
  938. return False
  939. if waitClickImg_noWait_withBool(check_img.visit_enter, 2, 1) == False:
  940. return False
  941. elif waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  942. return False
  943. while waitFindImg_withBool(special_activity_img.done_immediately, 1, 0.5) == False:
  944. if waitClickImg_noWait_withBool(special_activity_img.quick_choose, 1, 0.5) == False:
  945. return False
  946. while waitFindImg_withBool(special_activity_img.done_immediately, 1, 0.5):
  947. if waitClickImg_noWait_withBool(special_activity_img.choose_zero, 1, 0.5) == False:
  948. return False
  949. else:
  950. myTimeSleep_big()
  951. pcacc_mouse.input_string(str(self.cureNum))
  952. if self.continueCure == False:
  953. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  954. return False
  955. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  956. return False
  957. else:
  958. maxCureSoilder = 50000
  959. maxTryTimes = int(maxCureSoilder) // int(self.cureNum) * 2
  960. while waitClickImg_noWait_withBool((check_img.cure, check_img.help4, check_img.help5), 10, 0.2) and maxTryTimes >= 0:
  961. maxTryTimes -= 1
  962. continue
  963. waitClickImg_noWait_withBool((check_img.help4, check_img.help5), 1, 1)
  964. return True
  965. class task_useAnnimalSkill(dongri_task):
  966. def __init__(self, isFight = False):
  967. self.isFight = isFight
  968. super().__init__(f"使用动物技能")
  969. def run(self):
  970. basic_operate.go_outside()
  971. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  972. return False
  973. research_skill = [check_img.wolf_skill, check_img.elephant_skill, check_img.lu_skill]
  974. fight_skill = [check_img.fightWolf_skill, check_img.bird_skill, check_img.bear_skill, check_img.lion_skill]
  975. if self.isFight == False:
  976. if waitClickImg_noWait_withBool(research_skill, 2, 1) == False:
  977. return False
  978. else:
  979. if waitClickImg_noWait_withBool(fight_skill, 2, 1) == False:
  980. return False
  981. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  982. return False
  983. class task_activity_lianmeng(dongri_task):
  984. def __init__(self):
  985. super().__init__(f"联盟总动员")
  986. def run(self):
  987. basic_operate.go_town()
  988. myTimeSleep_big()
  989. if waitClickImg_noWait_withBool(special_activity_img.normal, 1, 0.5) == False:
  990. return False
  991. lianmeng_arr = [special_activity_img.lianmeng, special_activity_img.lianmeng2, special_activity_img.lianmeng3]
  992. while waitClickImg_noWait_withBool(lianmeng_arr, 1, 0.5) == False:
  993. yys_dragAuto(special_activity_img.move_left)
  994. myTimeSleep_small()
  995. if waitClickImg_noWait_withBool(lianmeng_arr, 1, 0.5) == True:
  996. break
  997. yys_dragAuto(special_activity_img.move_left)
  998. myTimeSleep_small()
  999. if waitClickImg_noWait_withBool(lianmeng_arr, 1, 0.5) == True:
  1000. break
  1001. yys_dragAuto(special_activity_img.move_right_little)
  1002. myTimeSleep_small()
  1003. if waitClickImg_noWait_withBool(lianmeng_arr, 1, 0.5) == True:
  1004. break
  1005. yys_dragAuto(special_activity_img.move_right_little)
  1006. myTimeSleep_small()
  1007. if waitClickImg_noWait_withBool(lianmeng_arr, 1, 0.5) == True:
  1008. break
  1009. return False
  1010. doTask_arr = [special_activity_img.shili_120_2, special_activity_img.shili_860_2, special_activity_img.shili_430, special_activity_img.bigMonster_2]
  1011. waitClickImg_noWait_withBool(special_activity_img.task_done, 1, 0.5)
  1012. if waitFindImg_withBool(special_activity_img.doing_task, 1, 0.5) == False:
  1013. down_tryTimes = 3
  1014. while down_tryTimes > 0:
  1015. down_tryTimes -= 1
  1016. if waitClickImg_noWait_withBool(doTask_arr, 1, 0.5, True) == True:
  1017. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  1018. return False
  1019. break
  1020. elif waitFindImg_withBool(special_activity_img.shili_2, 1, 0.5) == True:
  1021. save_game_screen("shili")
  1022. yys_dragAuto(special_activity_img.move_down)
  1023. up_tryTimes = 5
  1024. while up_tryTimes > 0:
  1025. up_tryTimes -= 1
  1026. myTimeSleep_small()
  1027. yys_dragAuto(change_direction(special_activity_img.move_down))
  1028. if waitFindImg_withBool((special_activity_img.shili_120, special_activity_img.shili_860_2), 2, 1, True) == False:
  1029. maxTryTimes = 2
  1030. while waitClickImg_noWait_withBool((special_activity_img.owning2), 2, 1) == True:
  1031. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  1032. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  1033. maxTryTimes -= 1
  1034. if maxTryTimes <= 0:
  1035. break
  1036. return True
  1037. class task_checkMaster(dongri_task):
  1038. def __init__(self):
  1039. super().__init__(f"检查统帅")
  1040. def run(self):
  1041. basic_operate.go_town()
  1042. if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
  1043. return False
  1044. if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
  1045. return False
  1046. myTimeSleep_big()
  1047. pcacc_mouse.quickclick_current()
  1048. if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
  1049. return False
  1050. return True
  1051. class task_checkActivities(dongri_task):
  1052. def __init__(self):
  1053. super().__init__(f"检查各种活动时间")
  1054. def find_all_matching_events(self, parts, input_word):
  1055. results = []
  1056. # 查找所有包含输入关键词的项
  1057. matches = [i for i, part in enumerate(parts) if input_word in part]
  1058. for match_index in matches:
  1059. # 从匹配项开始向后查找第一个时间或状态
  1060. for i in range(match_index + 1, len(parts)):
  1061. current_part = parts[i]
  1062. # 检查是否是时间(如 19:30)或状态(如 已结束)
  1063. if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
  1064. dst = {"item":parts[match_index], "time":current_part}
  1065. results.append(dst)
  1066. break # 找到第一个匹配就停止
  1067. return results
  1068. def run(self):
  1069. global todo_msg, todo_list
  1070. basic_operate.go_outside()
  1071. if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
  1072. return False
  1073. if waitFindImg_withBool(check_img.todoList, 2, 0) == False:
  1074. return False
  1075. myTimeSleep_small()
  1076. yys_dragAuto(check_img.move_down)
  1077. yys_dragAuto(check_img.move_down)
  1078. myTimeSleep_small()
  1079. activityStr = yys_ocrAuto(check_img.todo_region)
  1080. if activityStr:
  1081. todo_msg = activityStr
  1082. print(todo_msg)
  1083. date_pattern = r"\d{4}-\d{2}-\d{2}"
  1084. for i, item in enumerate(todo_msg):
  1085. if re.fullmatch(date_pattern, item): # 检查是否完全匹配日期格式
  1086. activityStr = todo_msg[:i] # 保留日期之前的内容
  1087. break
  1088. else:
  1089. activityStr = todo_msg # 如果没有找到日期,保留全部
  1090. print("去掉日期",activityStr)
  1091. result = []
  1092. judianArr = self.find_all_matching_events(activityStr, "据点")
  1093. #result.extend(judianArr)
  1094. baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
  1095. #result.extend(baoleiArr)
  1096. juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
  1097. result.extend(juxiongArr)
  1098. binggongchangArr = self.find_all_matching_events(activityStr, "兵工厂")
  1099. result.extend(binggongchangArr)
  1100. yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
  1101. #result.extend(yaosaiArr)
  1102. todo_list = result
  1103. print(todo_list)
  1104. print(get_todo_time("巨熊行动"))
  1105. return activityStr
  1106. class task_visit_island(dongri_task):
  1107. def __init__(self):
  1108. super().__init__(f"访问岛屿")
  1109. def run(self):
  1110. basic_operate.go_outside()
  1111. if waitClickImg_noWait_withBool(check_img.visit_island_small, 2, 1) == False:
  1112. return False
  1113. if waitClickImg_noWait_withBool(check_img.visit_enter, 2, 1) == False:
  1114. return False
  1115. if waitClickImg_noWait_withBool(check_img.visit_island_big, 2, 1) == False:
  1116. return False
  1117. return True
  1118. class task_fight_ranshuang(dongri_task):
  1119. def __init__(self):
  1120. super().__init__(f"打燃霜")
  1121. def run(self):
  1122. basic_operate.backToGame()
  1123. while True:
  1124. if waitClickImg_noWait_withBool(monster_img.ranshuang_search, 0.5, 0.5) == False:
  1125. return False
  1126. if waitClickImg_noWait_withBool(monster_img.ranshuang_attack, 0.5, 0.5) == False:
  1127. firstPos = get_yys_random_point(special_activity_img.mid_enemy_region)
  1128. pcacc_mouse.click(firstPos[0], firstPos[1])
  1129. myTimeSleep_big()
  1130. if waitClickImg_noWait_withBool(monster_img.ranshuang_attack, 1, 0.5) == False:
  1131. break
  1132. break
  1133. if waitClickImg_noWait_withBool([monster_img.fight, monster_img.fight2], 1, 0.5) == False:
  1134. return False
  1135. return True
  1136. class task_fight_enemy(dongri_task):
  1137. def __init__(self):
  1138. super().__init__(f"打敌人or王城")
  1139. def run(self):
  1140. basic_operate.go_town()
  1141. basic_operate.go_outside()
  1142. if waitClickImg_noWait_withBool(special_activity_img.collection, 2, 1) == False:
  1143. return False
  1144. if waitClickImg_noWait_withBool(special_activity_img.enemy, 2, 1) == False:
  1145. return False
  1146. attackArr = [monster_img.attack, monster_img.attack2, monster_img.ranshuang_attack, monster_img.outside_attack, monster_img.defend]
  1147. myTimeSleep_big()
  1148. firstPos = get_yys_random_point(special_activity_img.first_enemy_region)
  1149. pcacc_mouse.click(firstPos[0], firstPos[1])
  1150. maxTryTimes = 5
  1151. if waitFindImg_withBool(special_activity_img.visit_island, 1, 1) == True:
  1152. return False
  1153. while waitFindImg_withBool(attackArr, 1, 0) == False and maxTryTimes > 0:
  1154. if waitClickImg_noWait_withBool(special_activity_img.outside_soilder, 1, 1) == True:
  1155. break
  1156. #if waitFindImg_withBool(special_activity_img.outside_pcacc, 1, 1) == True:
  1157. # break
  1158. #else:
  1159. # return False
  1160. maxTryTimes -= 1
  1161. myTimeSleep_big()
  1162. mid_enemy_pos = get_yys_random_point(special_activity_img.mid_enemy_region)
  1163. pcacc_mouse.click(mid_enemy_pos[0], mid_enemy_pos[1])
  1164. myTimeSleep_big()
  1165. if waitFindImg_withBool(special_activity_img.visit_island, 1, 1) == True:
  1166. return False
  1167. if waitClickImg_noWait_withBool(attackArr, 1, 0) == False:
  1168. return False
  1169. waitClickImg_noWait_withBool(monster_img.team_go, 2, 1)#派遣队伍
  1170. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  1171. return False
  1172. if waitClickImg_noWait_withBool([monster_img.fight, monster_img.fight2], 2, 1) == False:
  1173. return False
  1174. return True
  1175. class task_get_redPackage(dongri_task):
  1176. def __init__(self):
  1177. super().__init__(f"领取红包")
  1178. def run(self):
  1179. basic_operate.go_outside()
  1180. if waitClickImg_noWait_withBool((check_img.talk_in,check_img.talk_in2, check_img.talk_in3), 2, 1) == False:
  1181. return False
  1182. waitClickImg_noWait_withBool(check_img.talkin_world, 2, 1)
  1183. oldTime = time.time()
  1184. max_waitTime = get_nextTaskTime()
  1185. print(f"max_waitTime:{max_waitTime}")
  1186. if max_waitTime == 0:
  1187. max_waitTime = 150
  1188. 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]
  1189. runTimes = 0
  1190. while True:
  1191. if time.time() - oldTime > max_waitTime:
  1192. break
  1193. if runTimes % 10 == 0:
  1194. if waitFindImg_withBool([special_activity_img.red_package_end, special_activity_img.red_package_end2], 1, 0) == True:
  1195. waitClickImg_noWait_withBool(special_activity_img.red_package_close, 2, 0)
  1196. myTimeSleep_small()
  1197. yys_dragAuto(special_activity_img.move_down)
  1198. if True == waitClickImg_noWait_withBool(red_package_pics, 2, 0):
  1199. start_screenshot_thread("redPackage")
  1200. max_waitTime += 5
  1201. runTimes += 1
  1202. return True
  1203. class task_read_mails(dongri_task):
  1204. def __init__(self):
  1205. super().__init__(f"读邮件")
  1206. def run(self):
  1207. basic_operate.go_town()
  1208. if waitClickImg_noWait_withBool(check_img.mail_btn, 2, 1) == False:
  1209. return False
  1210. waitClickImg_noWait_withBool(check_img.mail_collect, 2, 1)
  1211. if waitClickImg_noWait_withBool(check_img.mail_union, 2, 1) == False:
  1212. return False
  1213. if waitClickImg_noWait_withBool(check_img.mail_read, 2, 1) == False:
  1214. return False
  1215. if waitClickImg_noWait_withBool(check_img.mail_system, 2, 1) == False:
  1216. return False
  1217. if waitClickImg_noWait_withBool(check_img.mail_read, 2, 1) == False:
  1218. return False
  1219. if waitClickImg_noWait_withBool(check_img.mail_reports, 2, 1) == False:
  1220. return False
  1221. if waitClickImg_noWait_withBool(check_img.mail_read, 2, 1) == False:
  1222. return False
  1223. return True
  1224. class task_checkBenifitStatus(dongri_task):
  1225. def __init__(self):
  1226. super().__init__(f"查看增益状态")
  1227. def run(self):
  1228. basic_operate.go_town()
  1229. if waitFindImg_withBool(check_img.benefit_collect, 2, 1) == True:
  1230. return True
  1231. if waitClickImg_noWait_withBool(check_img.add_benefit, 2, 1) == False:
  1232. return False
  1233. waitClickImg_noWait_withBool(check_img.benefit_evolve, 2, 1)
  1234. if waitClickImg_noWait_withBool(check_img.benefit_collect_info, 2, 1) == False:
  1235. return False
  1236. myTimeSleep_big()
  1237. dstPos = get_yys_random_point(check_img.benefit_use_region)
  1238. pcacc_mouse.click(dstPos[0], dstPos[1])
  1239. myTimeSleep_big()
  1240. if waitClickImg_noWait_withBool(check_img.benefit_buy, 2, 1) == False:
  1241. return False
  1242. waitClickImg_noWait_withBool(check_img.buy_enter, 2, 1)
  1243. return True
  1244. class task_checkDiamond(dongri_task):
  1245. def __init__(self):
  1246. super().__init__(f"查看钻石活动")
  1247. def run(self):
  1248. basic_operate.go_town()
  1249. if waitClickImg_noWait_withBool(check_img.worthy_activity, 2, 1) == False:
  1250. return False
  1251. myTimeSleep_big()
  1252. yys_dragAuto(change_direction(special_activity_img.move_left))
  1253. myTimeSleep_big()
  1254. yys_dragAuto(change_direction(special_activity_img.move_left))
  1255. myTimeSleep_big()
  1256. yys_dragAuto(change_direction(special_activity_img.move_left))
  1257. if waitClickImg_noWait_withBool(check_img.diamond_activity, 2, 1) == False:
  1258. return False
  1259. waitClickImg_noWait_withBool(check_img.gain_diamond, 2, 1)
  1260. dstPos = get_yys_random_point(check_img.diamond_save)
  1261. pcacc_mouse.click(dstPos[0], dstPos[1])
  1262. myTimeSleep_big()
  1263. dstPos = get_yys_random_point(check_img.diamond_saveMax)
  1264. pcacc_mouse.click(dstPos[0], dstPos[1])
  1265. myTimeSleep_big()
  1266. if waitClickImg_noWait_withBool(check_img.diamond_save_btn, 2, 1) == False:
  1267. return False
  1268. return True
  1269. class task_fight_campion(dongri_task):
  1270. def __init__(self):
  1271. super().__init__(f"打竞技场")
  1272. def run(self):
  1273. basic_operate.go_town()
  1274. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  1275. return False
  1276. myTimeSleep_big()
  1277. if waitClickImg_noWait_withBool(special_activity_img.goto_arrow, 2, 1) == False:
  1278. return False
  1279. myTimeSleep_big()
  1280. maxMoveTimes = 2
  1281. while maxMoveTimes > 0:
  1282. maxMoveTimes -= 1
  1283. yys_dragAuto(special_activity_img.champion_move)
  1284. myTimeSleep_big()
  1285. if waitClickImg_noWait_withBool(special_activity_img.enter_champion, 2, 1) == True:
  1286. break
  1287. if waitClickImg_noWait_withBool(special_activity_img.champion_fight, 2, 1) == False:
  1288. return False
  1289. myTimeSleep_big()
  1290. dstPos = get_yys_random_point(special_activity_img.fight_last)
  1291. pcacc_mouse.click(dstPos[0], dstPos[1])
  1292. myTimeSleep_big()
  1293. if waitClickImg_noWait_withBool(special_activity_img.champion_fight2, 2, 1) == False:
  1294. return False
  1295. return True
  1296. class check_safe_collect(dongri_task):
  1297. def __init__(self):
  1298. super().__init__(f"检查安全收集")
  1299. def run(self):
  1300. basic_operate.go_outside()
  1301. if waitClickImg_noWait_withBool(special_activity_img.collection, 2, 1) == False:
  1302. return False
  1303. if waitClickImg_noWait_withBool(special_activity_img.collection_friend, 2, 1) == False:
  1304. return False
  1305. myTimeSleep_big()
  1306. firstPos = get_yys_random_point(special_activity_img.first_enemy_region)
  1307. pcacc_mouse.click(firstPos[0], firstPos[1])
  1308. maxTryTimes = 2
  1309. while waitClickImg_noWait_withBool(monster_img.collect, 1, 1) == False and maxTryTimes > 0:
  1310. maxTryTimes -= 1
  1311. myTimeSleep_big()
  1312. mid_enemy_pos = get_yys_random_point(special_activity_img.mid_enemy_region)
  1313. pcacc_mouse.click(mid_enemy_pos[0], mid_enemy_pos[1]-40)
  1314. myTimeSleep_big()
  1315. if waitClickImg_noWait_withBool(special_activity_img.big_collect, 2, 1) == False:
  1316. return False
  1317. if waitClickImg_noWait_withBool(monster_img.line7, 2, 1) == False:
  1318. return False
  1319. maxTryTimes = 3
  1320. while maxTryTimes > 0:
  1321. maxTryTimes -= 1
  1322. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  1323. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  1324. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  1325. break
  1326. return True
  1327. class task_duanwu(dongri_task):
  1328. def __init__(self):
  1329. super().__init__(f"端午")
  1330. def run(self):
  1331. count = 0
  1332. while True:
  1333. if count > 15000:
  1334. waitClickImg_noWait_withBool(special_activity_img.duanwu_auto_attack, 2, 1)
  1335. waitClickImg_noWait_withBool(special_activity_img.duanwu_auto_use, 2, 1)
  1336. else:
  1337. waitClickImg_noWait_withBool(special_activity_img.duanwu_end, 2, 1)
  1338. countStr = yys_ocrAuto(special_activity_img.orc_count)
  1339. print(countStr)
  1340. if len(countStr) == 0:
  1341. count = 0
  1342. continue
  1343. cleaned_text = countStr[0].replace('.', '')
  1344. cleaned_text = cleaned_text.replace(',', '')
  1345. try:
  1346. count = int(cleaned_text)
  1347. except:
  1348. continue
  1349. print("current count:", count)
  1350. return True
  1351. class task_checkPower(dongri_task):
  1352. def __init__(self):
  1353. super().__init__(f"检查实力")
  1354. def run(self):
  1355. countStr = yys_ocrAuto(special_activity_img.orc_power2)
  1356. if len(countStr) == 0:
  1357. count = 0
  1358. return 0
  1359. cleaned_text = countStr[0].replace('.', '')
  1360. cleaned_text = cleaned_text.replace(',', '')
  1361. try:
  1362. count = int(cleaned_text)
  1363. except:
  1364. return False
  1365. print("current count:", count)
  1366. return count
  1367. class task_get_fire_crystal(dongri_task):
  1368. def __init__(self):
  1369. super().__init__(f"获取火晶")
  1370. def run(self):
  1371. basic_operate.go_town()
  1372. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  1373. return False
  1374. myTimeSleep_big()
  1375. if waitClickImg_noWait_withBool(special_activity_img.spear, 2, 1) == False:
  1376. return False
  1377. if waitClickImg_noWait_withBool(special_activity_img.build_fire_crystal, 2, 1) == False:
  1378. return False
  1379. while waitClickImg_noWait_withBool(special_activity_img.fire_crystal_get, 2, 1, True) == True:
  1380. continue
  1381. return True
  1382. class task_testFun(dongri_task):
  1383. def __init__(self):
  1384. super().__init__(f"测试功能")
  1385. def run(self):
  1386. #task_checkDiamond().run()
  1387. task_paticipateInTeam2().run()
  1388. return True
  1389. if __name__ == '__main__':
  1390. myTimeSleep_big()
  1391. #task_get_fire_crystal().run()
  1392. #task_checkPower().run()
  1393. #task_testFun().run()
  1394. #task_checkActivities().run()
  1395. #print(get_todo_time("巨熊行动"))
  1396. #task_check_Research().run()
  1397. #save_game_screen()
  1398. #basic_operate.get_line_num()
  1399. #task_cure(True, 85).run()
  1400. #task_fight_enemy().run()
  1401. #task_fight_ranshuang().run()
  1402. #task_gotoTree().run()
  1403. #task_fight_jina_only().run()
  1404. #task_checkConfilits().run()
  1405. #task_getStrength().run()
  1406. #task_checkActivities().run()
  1407. #task_checkMaster().run()
  1408. #basic_operate.get_line_num()
  1409. #yys_ocrAuto(check_img.line_orc)
  1410. #basic_operate.go_town()
  1411. #basic_operate.add_strength()
  1412. #task_fightMonster(False, True,False).run()
  1413. #task_checkHelp().run()
  1414. #task_checkStoreRoom().run()
  1415. #task_start_game(1)
  1416. #check_safe_collect().run()
  1417. #task_fight_campion().run()
  1418. #task_activity_lianmeng().run()
  1419. #task_fight_yongbing(True).run()
  1420. #task_collect([4,3,2,1]).run()
  1421. #task_train("upgrade").run()
  1422. #task_information(True).run()
  1423. #check_buildOrResearch().run()
  1424. #task_checkDonata().run()
  1425. #task_collect(1).run()
  1426. #task_collect(2).run()
  1427. #task_collect(3).run()
  1428. #task_collect(4).run()
  1429. #task_returnAllLine().run()
  1430. task_paticipateInTeam().run()
  1431. #task_fight_jina(True).run()
  1432. #task_get_redPackage().run()
  1433. #task_read_mails().run()
  1434. #task_checkBenifitStatus().run()
  1435. #task_checkDiamond().run()