dongri_task.py 59 KB

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