dongri_task.py 53 KB

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