dongri_task.py 51 KB

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