dongri_task.py 60 KB

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