dongri_task.py 63 KB

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