dongri_task.py 59 KB

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