dongri_task.py 55 KB

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