dongri_task.py 62 KB

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