dongri_task.py 62 KB

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