dongri_task.py 59 KB

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