dongri_task.py 62 KB

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