dongri_task.py 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  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. '''
  22. 基础配置说明:
  23. 600*800(DPI 300)
  24. 游戏画面:流畅
  25. 高帧率关闭
  26. 町中模式:旧版
  27. '''
  28. todo_msg = ''
  29. todo_list = []
  30. def get_todo_msg():
  31. global todo_msg
  32. return todo_msg
  33. def get_todo_msgList():
  34. global todo_list
  35. todo_str = ''
  36. for item in todo_list:
  37. todo_str += f'{item["item"]}:{item["time"]}</br>'
  38. return todo_str
  39. def fing_todoList_time(taskStr):
  40. for item in todo_list:
  41. if item['task'] == taskStr:
  42. return item['time']
  43. def task_getComputerName():
  44. return socket.gethostname()
  45. def task_acceptTask():
  46. while True:
  47. myTimeSleep_big()
  48. def init():
  49. global _imported
  50. if not _imported:
  51. acceptTask = threading.Thread(target=task_acceptTask)
  52. acceptTask.daemon = True
  53. if acceptTask.is_alive() == False:
  54. acceptTask.start()
  55. _imported = True
  56. class basic_operate:
  57. @staticmethod
  58. def do_back():
  59. task_return_game()
  60. ret = False
  61. ret |= waitClickImg_noWait_withBool(place_img.back1, 0.6, 0)
  62. if ret:
  63. return
  64. ret |= waitClickImg_noWait_withBool(place_img.back2, 0.6, 0)
  65. if ret:
  66. return
  67. ret |= waitClickImg_noWait_withBool(place_img.back3, 0.6, 0)
  68. if ret:
  69. return
  70. ret, pos = waitFindImg(place_img.title, 1, 0)
  71. if ret:
  72. pcacc_mouse.click(pos[0] + 20, pos[1] + 80)
  73. def backToGame(preTime = 0):
  74. tryMaxTimes = 5
  75. while tryMaxTimes > 0:
  76. tryMaxTimes -= 1
  77. if waitFindImg_withBool(place_img.gameIn, 1, preTime) == False:
  78. basic_operate.do_back()
  79. else:
  80. return True
  81. return False
  82. @staticmethod
  83. def go_town(preTime = 0):
  84. if basic_operate.backToGame(preTime) == False:
  85. return False
  86. waitClickImg_noWait_withBool(place_img.outside, 0.6, 0)
  87. return True
  88. @staticmethod
  89. def go_outside(preTime = 0):
  90. if basic_operate.backToGame(preTime) == False:
  91. return False
  92. waitClickImg_noWait_withBool(place_img.town, 0.6, 0)
  93. return True
  94. @staticmethod
  95. def click_outside_search():
  96. taskListRet, taskListPos = waitFindImg(monster_img.tasklist, 2, 3)
  97. if taskListRet == False:
  98. return False
  99. else:
  100. pcacc_mouse.click(taskListPos[0], taskListPos[1] - 110)#click search
  101. myTimeSleep_big()
  102. return True
  103. @staticmethod
  104. def enter_auto_supply_resource(enter_pic):
  105. if waitClickImg_noWait_withBool(enter_pic, 2, 2) == False:
  106. return False
  107. if waitClickImg_noWait_withBool(train_img.getAll, 2, 1) == False:
  108. return True
  109. if waitClickImg_noWait_withBool(train_img.enter, 2, 1) == False:
  110. return False
  111. if waitClickImg_noWait_withBool(enter_pic, 2, 1) == False:
  112. return False
  113. return True
  114. @staticmethod
  115. def return_line():
  116. if waitClickImg_noWait_withBool(monster_img.returnLine, 2, 1) == False:
  117. return False
  118. if waitClickImg_noWait_withBool(monster_img.enter, 2, 1) == False:
  119. return False
  120. return True
  121. @staticmethod
  122. def add_strength():
  123. if waitClickImg_noWait_withBool(check_img.no_strength, 2, 1) == False:
  124. return False
  125. if waitClickImg_noWait_withBool(check_img.add_strength, 2, 1) == False:
  126. return False
  127. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  128. return False
  129. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  130. return False
  131. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  132. return False
  133. return True
  134. @staticmethod
  135. def get_line_num():
  136. lineStr = yys_ocrAuto(check_img.line_orc)
  137. if len(lineStr) == 0:
  138. return 0
  139. match = re.search(r'\d', lineStr[0]) # 查找第一个数字
  140. if match:
  141. first_digit = match.group()
  142. print("第一个数字:", first_digit)
  143. return int(first_digit)
  144. else:
  145. print("未找到数字")
  146. return 0
  147. def task_return_game():
  148. tryTimes = 3
  149. while tryTimes > 0:
  150. if False == waitFindImg_withBool([place_img.title], 1, 1):
  151. waitClickImg_noWait([place_img.ico, place_img.ico2], 1, 0)
  152. myTimeSleep_big()
  153. tryTimes -= 1
  154. if tryTimes == 0:
  155. return False
  156. else:
  157. break
  158. def task_save_compress_pic():
  159. # 截取屏幕截图
  160. screenshot = pyautogui.screenshot()
  161. compressed_data = compress_image(screenshot)
  162. # 保存压缩后的图像到文件
  163. with open('compressed_screenshot.jpg', 'wb') as f:
  164. f.write(compressed_data)
  165. def task_close_game():
  166. subprocess.call(f"taskkill /f /im MuMuPlayer.exe")
  167. subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
  168. subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
  169. myTimeSleep_big()
  170. def task_start_game():
  171. isSuccess = True
  172. path1 = R'C:\\Program Files\\Netease\\MuMuPlayer-12.0\\shell\\MuMuPlayer.exe'
  173. path2 = R'C:\Program Files\Netease\MuMu Player 12\shell\MuMuPlayer.exe'
  174. if os.path.exists(path1):
  175. subprocess.Popen(path1)
  176. elif os.path.exists(path2):
  177. subprocess.Popen(path2)
  178. if waitClickImg_withBool(gameStart_img.ico, 100, 20) == False:
  179. return False
  180. waitFindImg_withBool(place_img.gameIn, 10, 20)
  181. basic_operate.go_town()
  182. waitFindImg_withBool(place_img.gameIn, 10, 20)
  183. basic_operate.go_town()
  184. if waitFindImg_withBool(place_img.gameIn, 10, 20) == False:
  185. return False
  186. myTimeSleep_big()
  187. return isSuccess
  188. class dongri_task:
  189. def __init__(self, name):
  190. self.name = name
  191. def run(self):
  192. print(f"Running task: {self.name}")
  193. class task_fight_yongbing(dongri_task):
  194. def __init__(self, add_strengh):
  195. super().__init__("战斗佣兵")
  196. self.add_strengh = add_strengh
  197. def run(self):
  198. basic_operate.go_outside()
  199. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  200. if self.add_strengh:
  201. basic_operate.add_strength()
  202. basic_operate.go_outside()
  203. else:
  204. print("没有足够的体力了")
  205. return False
  206. if waitClickImg_noWait_withBool(check_img.yongbing, 2, 1) == False:
  207. return False
  208. if waitClickImg_noWait_withBool(check_img.detect, 2, 1) == False:
  209. return False
  210. if waitClickImg_noWait_withBool(check_img.yongbing_fight, 2, 1) == False:
  211. return False
  212. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  213. return False
  214. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  215. return False
  216. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  217. return False
  218. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  219. maxTryTimes = 3
  220. while maxTryTimes > 0:
  221. maxTryTimes -= 1
  222. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  223. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  224. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  225. break
  226. return True
  227. class task_fight_jina_only(dongri_task):
  228. def __init__(self):
  229. super().__init__("战斗召唤的吉娜")
  230. def run(self):
  231. basic_operate.go_outside()
  232. #必须加体力
  233. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  234. basic_operate.add_strength()
  235. basic_operate.go_outside()
  236. if waitClickImg_noWait_withBool((check_img.talk_in,check_img.talk_in2), 2, 1) == False:
  237. return False
  238. waitClickImg_noWait_withBool(check_img.talkin_person, 2, 1)
  239. if waitClickImg_noWait_withBool(check_img.talkin_jina, 2, 1) == False:
  240. return False
  241. myTimeSleep_big()
  242. yys_dragAuto(check_img.move_down)
  243. yys_dragAuto(check_img.move_down)
  244. myTimeSleep_big()
  245. if waitClickImg_noWait_withBool(check_img.xiaohao_jina, 2, 1) == False:
  246. return False
  247. if waitClickImg_noWait_withBool((check_img.jina_pic, check_img.jina_pic2), 2, 1) == False:
  248. return False
  249. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  250. return False
  251. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  252. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  253. return False
  254. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  255. return False
  256. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  257. return False
  258. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  259. maxTryTimes = 3
  260. while maxTryTimes > 0:
  261. maxTryTimes -= 1
  262. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  263. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  264. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  265. break
  266. return True
  267. class task_call_jina(dongri_task):
  268. def __init__(self):
  269. super().__init__("召唤吉娜")
  270. def run(self):
  271. basic_operate.go_outside()
  272. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  273. return False
  274. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  275. return False
  276. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  277. return False
  278. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  279. return False
  280. if waitClickImg_noWait_withBool(check_img.share, 2, 1) == False:
  281. return False
  282. if waitClickImg_noWait_withBool(check_img.to_pcacc, 2, 1) == False:
  283. return False
  284. if waitClickImg_noWait_withBool(check_img.share_btn, 2, 1) == False:
  285. return False
  286. return True
  287. class task_fight_jina(dongri_task):
  288. def __init__(self, add_strengh):
  289. super().__init__("战斗吉娜")
  290. self.add_strengh = add_strengh
  291. def run(self):
  292. basic_operate.go_outside()
  293. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  294. if self.add_strengh:
  295. basic_operate.add_strength()
  296. basic_operate.go_outside()
  297. else:
  298. print("没有足够的体力了")
  299. return False
  300. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  301. return False
  302. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  303. return False
  304. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  305. return False
  306. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  307. return False
  308. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  309. return False
  310. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  311. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  312. return False
  313. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  314. return False
  315. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  316. return False
  317. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  318. maxTryTimes = 3
  319. while maxTryTimes > 0:
  320. maxTryTimes -= 1
  321. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  322. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  323. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  324. break
  325. return True
  326. class task_fightMonster(dongri_task):
  327. def __init__(self, add_strengh, fight_bigMonster, isSimple):
  328. self.add_strengh = add_strengh
  329. self.isSimple = isSimple
  330. if fight_bigMonster == True:
  331. super().__init__(f"战斗大怪物")
  332. self.monster = monster_img.bigMonster
  333. self.attack = monster_img.muti_team
  334. else:
  335. super().__init__(f"战斗小怪物")
  336. self.monster = monster_img.wolf
  337. self.attack = monster_img.attack
  338. def run(self):
  339. basic_operate.go_outside()
  340. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  341. if self.add_strengh:
  342. basic_operate.add_strength()
  343. basic_operate.go_outside()
  344. else:
  345. print("没有足够的体力了")
  346. return False
  347. if False == basic_operate.click_outside_search():
  348. return False
  349. if self.add_strengh and basic_operate.get_line_num() >= 6:
  350. return False
  351. if waitFindImg_withBool(monster_img.search, 2, 1):
  352. myTimeSleep_big()
  353. yys_dragAuto(monster_img.move_left)
  354. if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
  355. return False
  356. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  357. return False
  358. if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
  359. return False
  360. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  361. if not self.isSimple:
  362. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  363. return False
  364. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  365. return False
  366. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  367. return False
  368. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  369. maxTryTimes = 3
  370. while maxTryTimes > 0:
  371. maxTryTimes -= 1
  372. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  373. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  374. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  375. break
  376. return True
  377. class task_collect(dongri_task):
  378. def __init__(self, type = 0, isSimple = False, isAddStrenghth = False):
  379. self.isSimple = isSimple
  380. self.isAddStrenghth = isAddStrenghth
  381. if isinstance(type, (list, tuple)):
  382. typeArr = type
  383. type = typeArr[random.randint(0, len(typeArr) - 1)]
  384. elif type == 0:
  385. typeArr = [4,4,3,3,3,2,2,2,1,1]
  386. type = typeArr[random.randint(0, len(typeArr) - 1)]
  387. elif type == 5:
  388. typeArr = [2,1]
  389. type = typeArr[random.randint(0, len(typeArr) - 1)]
  390. if type == 1:
  391. self.type = monster_img.meat
  392. self.line = monster_img.line2
  393. super().__init__(f"采集肉")
  394. elif type == 2:
  395. self.type = monster_img.wood
  396. self.line = monster_img.line3
  397. super().__init__(f"采集木头")
  398. elif type == 3:
  399. self.type = monster_img.mine
  400. self.line = monster_img.line4
  401. super().__init__(f"采矿石")
  402. elif type == 4:
  403. self.type = monster_img.iron
  404. self.line = monster_img.line5
  405. super().__init__(f"采集铁矿石")
  406. else:
  407. self.type = None
  408. self.line = None
  409. super().__init__(f"采集None")
  410. if isSimple:
  411. self.line = None
  412. def run(self):
  413. if self.type == None:
  414. return True
  415. basic_operate.go_outside()
  416. maxLineNum = 6
  417. if self.isSimple:
  418. if self.isAddStrenghth:
  419. maxLineNum = 3
  420. else:
  421. maxLineNum = 4
  422. else:
  423. if self.isAddStrenghth:
  424. maxLineNum = 5
  425. else:
  426. maxLineNum = 6
  427. if basic_operate.get_line_num() >= maxLineNum:
  428. return False
  429. if False == basic_operate.click_outside_search():
  430. return False
  431. if waitFindImg_withBool(monster_img.search, 2, 1):
  432. myTimeSleep_big()
  433. yys_dragAuto(monster_img.move_right)
  434. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  435. return False
  436. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  437. return False
  438. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  439. return False
  440. if self.line != None:
  441. waitClickImg_noWait_withBool(self.line, 2, 1)
  442. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  443. return False
  444. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  445. maxTryTimes = 3
  446. while maxTryTimes > 0:
  447. maxTryTimes -= 1
  448. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  449. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  450. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  451. break
  452. return True
  453. class task_train(dongri_task):
  454. def __init__(self, train_type = None):
  455. super().__init__(f"检查训练{train_type}")
  456. self.train_type = train_type
  457. def run(self):
  458. basic_operate.go_town()
  459. if self.train_type == 'None':
  460. return True
  461. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  462. return False
  463. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  464. return False
  465. tryTimes = 3
  466. while tryTimes > 0:
  467. tryTimes -= 1
  468. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  469. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  470. break
  471. if self.train_type == 'lv1':
  472. myTimeSleep_big()
  473. yys_dragAuto(train_img.move_left)
  474. yys_dragAuto(train_img.move_left)
  475. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  476. elif self.train_type == 'lv8':
  477. waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
  478. elif self.train_type == 'lv9':
  479. waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
  480. return basic_operate.enter_auto_supply_resource(train_img.begin_train)
  481. class task_checkHelp(dongri_task):
  482. def __init__(self, isOutSide = False):
  483. super().__init__(f"检查帮助")
  484. self.isOutSide = isOutSide
  485. def run(self):
  486. if self.isOutSide:
  487. basic_operate.go_outside()
  488. else:
  489. basic_operate.go_town()
  490. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  491. return True
  492. class task_gotoTree(dongri_task):
  493. def __init__(self):
  494. super().__init__(f"查看生命之树")
  495. def run(self):
  496. basic_operate.go_town()
  497. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  498. return False
  499. myTimeSleep_big()
  500. yys_dragAuto(check_img.move_down)
  501. yys_dragAuto(check_img.move_down)
  502. myTimeSleep_big()
  503. if waitClickImg_noWait_withBool(check_img.life_tree, 2, 1) == False:
  504. return False
  505. return True
  506. class task_checkStoreRoom(dongri_task):
  507. def __init__(self):
  508. super().__init__(f"检查仓库或招募")
  509. def run(self):
  510. basic_operate.go_town()
  511. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  512. return False
  513. myTimeSleep_big()
  514. yys_dragAuto(check_img.move_down)
  515. yys_dragAuto(check_img.move_down)
  516. myTimeSleep_big()
  517. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  518. return False
  519. myTimeSleep_big()
  520. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
  521. waitClickImg_noWait_withBool(check_img.bigGet, 2, 1)
  522. pcacc_mouse.quickclick_current()
  523. myTimeSleep_big()
  524. if waitClickImg_noWait_withBool((check_img.detail,check_img.detail2), 2, 1):
  525. myTimeSleep_big()
  526. basic_operate.go_town()
  527. myTimeSleep_big()
  528. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  529. return False
  530. myTimeSleep_big()
  531. pcacc_mouse.quickclick_current()
  532. myTimeSleep_big()
  533. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  534. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  535. else:
  536. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  537. myTimeSleep_big()
  538. dstPos = get_yys_random_point(check_img.pet_getRegion)
  539. pcacc_mouse.click(dstPos[0], dstPos[1])
  540. myTimeSleep_big()
  541. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  542. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  543. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  544. return True
  545. class task_checkConfilits(dongri_task):
  546. def __init__(self):
  547. super().__init__(f"检查集结")
  548. def run(self):
  549. basic_operate.go_outside()
  550. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  551. return False
  552. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  553. return False
  554. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  555. return False
  556. return True
  557. class task_checkDonata(dongri_task):
  558. def __init__(self):
  559. super().__init__(f"检查捐献")
  560. def run(self):
  561. basic_operate.go_town()
  562. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  563. return False
  564. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  565. return False
  566. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  567. return False
  568. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  569. return False
  570. else:
  571. maxTryTimes = 3
  572. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  573. maxTryTimes -= 1
  574. return True
  575. class task_checkAdventure(dongri_task):
  576. def __init__(self):
  577. super().__init__(f"检查冒险")
  578. def run(self):
  579. basic_operate.go_town()
  580. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  581. return False
  582. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  583. return False
  584. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  585. return False
  586. return True
  587. class task_waitTime(dongri_task):
  588. def __init__(self):
  589. super().__init__(f"等待时间")
  590. def run(self):
  591. myTimeSleep(300)
  592. class check_buildOrResearch(dongri_task):
  593. def __init__(self):
  594. super().__init__(f"检查建筑或研究")
  595. def run(self):
  596. basic_operate.go_town()
  597. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  598. return False
  599. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  600. return False
  601. dstType = 'none'
  602. while True:
  603. 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):
  604. dstType = 'build'
  605. break
  606. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  607. if not handRet:
  608. return False
  609. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  610. dstPos = [0, 0]
  611. if not detailRet:
  612. # 如果找不到详细信息,兵营之类的,需点中间
  613. dstPos = [handPos[0] - 70, handPos[1] + 120]
  614. else:
  615. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  616. tryTimes = 5
  617. while tryTimes > 0:
  618. tryTimes -= 1
  619. myTimeSleep_big()
  620. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  621. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  622. dstType = 'research'
  623. break
  624. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  625. dstType = 'build'
  626. break
  627. break
  628. if dstType == 'none':
  629. print('没有找到建筑或研究')
  630. return False
  631. elif dstType == 'build':
  632. buildtimes = 4
  633. 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]):
  634. buildtimes -= 1
  635. if buildtimes == 0:
  636. break
  637. continue
  638. elif dstType == 'research':
  639. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  640. return False
  641. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  642. return False
  643. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  644. return True
  645. class task_information(dongri_task):
  646. def __init__(self, isAddStrengh = False):
  647. super().__init__(f"检查情报")
  648. self.isAddStrengh = isAddStrengh
  649. def run(self):
  650. basic_operate.go_outside()
  651. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  652. if self.isAddStrengh:
  653. basic_operate.add_strength()
  654. basic_operate.go_outside()
  655. else:
  656. print("没有足够的体力了")
  657. return False
  658. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  659. return False
  660. if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 0.5, 0.5):
  661. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  662. return False
  663. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  664. return False
  665. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  666. return False
  667. myTimeSleep_big()
  668. return True
  669. elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 0.5, 0.5):
  670. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  671. return False
  672. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  673. return False
  674. return True
  675. elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 0.5, 0.5):
  676. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  677. return False
  678. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  679. return False
  680. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  681. return False
  682. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  683. return False
  684. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  685. maxTryTimes = 3
  686. while maxTryTimes > 0:
  687. maxTryTimes -= 1
  688. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  689. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  690. break
  691. return True
  692. else:
  693. return False
  694. class task_returnAllLine(dongri_task):
  695. def __init__(self):
  696. super().__init__(f"返回所有路线")
  697. def run(self):
  698. basic_operate.go_outside()
  699. basic_operate.return_line()
  700. basic_operate.return_line()
  701. basic_operate.return_line()
  702. basic_operate.return_line()
  703. basic_operate.return_line()
  704. basic_operate.return_line()
  705. return True
  706. class task_paticipateInTeam(dongri_task):
  707. def __init__(self):
  708. super().__init__(f"参与队伍")
  709. def run(self):
  710. basic_operate.go_outside()
  711. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  712. return False
  713. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
  714. return False
  715. while True:
  716. if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
  717. break
  718. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  719. break
  720. if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
  721. break
  722. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  723. break
  724. break
  725. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  726. return False
  727. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  728. maxTryTimes = 3
  729. while maxTryTimes > 0:
  730. maxTryTimes -= 1
  731. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  732. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  733. break
  734. return True
  735. class task_cure(dongri_task):
  736. def __init__(self, continueCure = False, cureNum = None):
  737. super().__init__(f"治疗")
  738. self.continueCure = continueCure
  739. self.cureNum = cureNum
  740. def run(self):
  741. basic_operate.go_outside()
  742. if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  743. return False
  744. if self.continueCure == False:
  745. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  746. return False
  747. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  748. return False
  749. else:
  750. maxTryTimes = 50
  751. while waitClickImg_noWait_withBool((check_img.cure, check_img.help4), 30, 1) and maxTryTimes >= 0:
  752. maxTryTimes -= 1
  753. continue
  754. return True
  755. class task_useAnnimalSkill(dongri_task):
  756. def __init__(self):
  757. super().__init__(f"使用动物技能")
  758. def run(self):
  759. basic_operate.go_outside()
  760. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  761. return False
  762. if waitClickImg_noWait_withBool((check_img.wolf_skill, check_img.elephant_skill), 2, 1) == False:
  763. return False
  764. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  765. return False
  766. class task_activity_lianmeng(dongri_task):
  767. def __init__(self):
  768. super().__init__(f"联盟总动员")
  769. def run(self):
  770. basic_operate.go_town()
  771. if waitClickImg_noWait_withBool(special_activity_img.normal, 2, 1) == False:
  772. return False
  773. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2), 2, 1) == False:
  774. return False
  775. waitClickImg_noWait_withBool(special_activity_img.task_done, 2, 1)
  776. if waitFindImg_withBool(special_activity_img.doing_task, 2, 1) == False:
  777. if waitClickImg_noWait_withBool((special_activity_img.shili_120, special_activity_img.shili_860_2, special_activity_img.bigMonster), 2, 1) == True:
  778. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  779. return False
  780. if waitFindImg_withBool((special_activity_img.shili_120, special_activity_img.shili_860_2), 2, 1) == False:
  781. maxTryTimes = 2
  782. while waitClickImg_noWait_withBool((special_activity_img.owning, special_activity_img.owning_120), 2, 1) == True:
  783. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  784. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  785. maxTryTimes -= 1
  786. if maxTryTimes <= 0:
  787. break
  788. return True
  789. class task_checkMaster(dongri_task):
  790. def __init__(self):
  791. super().__init__(f"检查统帅")
  792. def run(self):
  793. basic_operate.go_town()
  794. if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
  795. return False
  796. if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
  797. return False
  798. myTimeSleep_big()
  799. pcacc_mouse.quickclick_current()
  800. if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
  801. return False
  802. return True
  803. class task_checkActivities(dongri_task):
  804. def __init__(self):
  805. super().__init__(f"检查各种活动时间")
  806. def find_all_matching_events(self, parts, input_word):
  807. results = []
  808. # 查找所有包含输入关键词的项
  809. matches = [i for i, part in enumerate(parts) if input_word in part]
  810. for match_index in matches:
  811. # 从匹配项开始向后查找第一个时间或状态
  812. for i in range(match_index + 1, len(parts)):
  813. current_part = parts[i]
  814. # 检查是否是时间(如 19:30)或状态(如 已结束)
  815. if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
  816. dst = {"item":parts[match_index], "time":current_part}
  817. results.append(dst)
  818. break # 找到第一个匹配就停止
  819. return results
  820. def run(self):
  821. global todo_msg, todo_list
  822. basic_operate.go_outside()
  823. if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
  824. return False
  825. if waitFindImg_withBool(check_img.todoList, 2, 1) == False:
  826. return False
  827. activityStr = yys_ocrAuto(check_img.todo_region)
  828. if activityStr:
  829. todo_msg = activityStr
  830. print(todo_msg)
  831. result = []
  832. judianArr = self.find_all_matching_events(activityStr, "据点")
  833. result.extend(judianArr)
  834. baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
  835. result.extend(baoleiArr)
  836. juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
  837. result.extend(juxiongArr)
  838. yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
  839. result.extend(yaosaiArr)
  840. todo_list = result
  841. print(todo_list)
  842. return activityStr
  843. if __name__ == '__main__':
  844. task_gotoTree().run()
  845. #task_fight_jina_only().run()
  846. #task_checkConfilits().run()
  847. #task_checkActivities().run()
  848. #task_checkMaster().run()
  849. #basic_operate.get_line_num()
  850. #yys_ocrAuto(check_img.line_orc)
  851. #basic_operate.go_town()
  852. #basic_operate.add_strength()
  853. #task_fightMonster(False, False,False).run()
  854. #task_checkHelp().run()
  855. #task_checkStoreRoom().run()
  856. #task_activity_lianmeng().run()
  857. #task_fight_yongbing(True).run()
  858. #task_collect([4,3,2,1]).run()
  859. #task_train("lv9").run()
  860. #task_information().run()
  861. #check_buildOrResearch().run()
  862. #task_checkDonata().run()
  863. #task_collect(1).run()
  864. #task_collect(2).run()
  865. #task_collect(3).run()
  866. #task_collect(4).run()
  867. #task_returnAllLine().run()
  868. #task_paticipateInTeam().run()
  869. #task_fight_jina(True).run()