dongri_task.py 63 KB

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