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