dongri_task.py 59 KB

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