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