dongri_task.py 61 KB

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