dongri_task.py 63 KB

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