dongri_task.py 60 KB

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