dongri_task.py 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  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. def task_getComputerName():
  29. return socket.gethostname()
  30. def task_acceptTask():
  31. while True:
  32. myTimeSleep_big()
  33. def init():
  34. global _imported
  35. if not _imported:
  36. acceptTask = threading.Thread(target=task_acceptTask)
  37. acceptTask.daemon = True
  38. if acceptTask.is_alive() == False:
  39. acceptTask.start()
  40. _imported = True
  41. class basic_operate:
  42. @staticmethod
  43. def do_back():
  44. task_return_game()
  45. ret = False
  46. ret |= waitClickImg_noWait_withBool(place_img.back1, 0.6, 0)
  47. if ret:
  48. return
  49. ret |= waitClickImg_noWait_withBool(place_img.back2, 0.6, 0)
  50. if ret:
  51. return
  52. ret |= waitClickImg_noWait_withBool(place_img.back3, 0.6, 0)
  53. if ret:
  54. return
  55. ret, pos = waitFindImg(place_img.title, 1, 0)
  56. if ret:
  57. pcacc_mouse.click(pos[0], pos[1] + 80)
  58. def backToGame(preTime = 0):
  59. tryMaxTimes = 5
  60. while tryMaxTimes > 0:
  61. tryMaxTimes -= 1
  62. if waitFindImg_withBool(place_img.gameIn, 1, preTime) == False:
  63. basic_operate.do_back()
  64. else:
  65. return True
  66. return False
  67. @staticmethod
  68. def go_town(preTime = 0):
  69. if basic_operate.backToGame(preTime) == False:
  70. return False
  71. waitClickImg_noWait_withBool(place_img.outside, 0.6, 0)
  72. return True
  73. @staticmethod
  74. def go_outside(preTime = 0):
  75. if basic_operate.backToGame(preTime) == False:
  76. return False
  77. waitClickImg_noWait_withBool(place_img.town, 0.6, 0)
  78. return True
  79. @staticmethod
  80. def click_outside_search():
  81. taskListRet, taskListPos = waitFindImg(monster_img.tasklist, 2, 3)
  82. if taskListRet == False:
  83. return False
  84. else:
  85. pcacc_mouse.click(taskListPos[0], taskListPos[1] - 110)#click search
  86. myTimeSleep_big()
  87. return True
  88. @staticmethod
  89. def enter_auto_supply_resource(enter_pic):
  90. if waitClickImg_noWait_withBool(enter_pic, 2, 2) == False:
  91. return False
  92. if waitClickImg_noWait_withBool(train_img.getAll, 2, 1) == False:
  93. return True
  94. if waitClickImg_noWait_withBool(train_img.enter, 2, 1) == False:
  95. return False
  96. if waitClickImg_noWait_withBool(enter_pic, 2, 1) == False:
  97. return False
  98. return True
  99. @staticmethod
  100. def return_line():
  101. if waitClickImg_noWait_withBool(monster_img.returnLine, 2, 1) == False:
  102. return False
  103. if waitClickImg_noWait_withBool(monster_img.enter, 2, 1) == False:
  104. return False
  105. return True
  106. @staticmethod
  107. def add_strength():
  108. if waitClickImg_noWait_withBool(check_img.no_strength, 2, 1) == False:
  109. return False
  110. if waitClickImg_noWait_withBool(check_img.add_strength, 2, 1) == False:
  111. return False
  112. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  113. return False
  114. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  115. return False
  116. if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
  117. return False
  118. return True
  119. @staticmethod
  120. def get_line_num():
  121. lineStr = yys_ocrAuto(check_img.line_orc)
  122. if len(lineStr) == 0:
  123. return 0
  124. match = re.search(r'\d', lineStr[0]) # 查找第一个数字
  125. if match:
  126. first_digit = match.group()
  127. print("第一个数字:", first_digit)
  128. return int(first_digit)
  129. else:
  130. print("未找到数字")
  131. return 0
  132. def task_return_game():
  133. tryTimes = 3
  134. while tryTimes > 0:
  135. if False == waitFindImg_withBool([place_img.title], 1, 1):
  136. waitClickImg_noWait([place_img.ico, place_img.ico2], 1, 0)
  137. myTimeSleep_big()
  138. tryTimes -= 1
  139. if tryTimes == 0:
  140. return False
  141. else:
  142. break
  143. def task_save_compress_pic():
  144. # 截取屏幕截图
  145. screenshot = pyautogui.screenshot()
  146. compressed_data = compress_image(screenshot)
  147. # 保存压缩后的图像到文件
  148. with open('compressed_screenshot.jpg', 'wb') as f:
  149. f.write(compressed_data)
  150. def task_close_game():
  151. subprocess.call(f"taskkill /f /im MuMuPlayer.exe")
  152. subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
  153. subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
  154. myTimeSleep_big()
  155. def task_start_game():
  156. isSuccess = True
  157. path1 = R'C:\\Program Files\\Netease\\MuMuPlayer-12.0\\shell\\MuMuPlayer.exe'
  158. path2 = R'C:\Program Files\Netease\MuMu Player 12\shell\MuMuPlayer.exe'
  159. if os.path.exists(path1):
  160. subprocess.Popen(path1)
  161. elif os.path.exists(path2):
  162. subprocess.Popen(path2)
  163. if waitClickImg_withBool(gameStart_img.ico, 100, 20) == False:
  164. return False
  165. waitFindImg_withBool(place_img.gameIn, 10, 20)
  166. basic_operate.go_town()
  167. waitFindImg_withBool(place_img.gameIn, 10, 20)
  168. basic_operate.go_town()
  169. if waitFindImg_withBool(place_img.gameIn, 10, 20) == False:
  170. return False
  171. myTimeSleep_big()
  172. return isSuccess
  173. class dongri_task:
  174. def __init__(self, name):
  175. self.name = name
  176. def run(self):
  177. print(f"Running task: {self.name}")
  178. class task_fight_yongbing(dongri_task):
  179. def __init__(self, add_strengh):
  180. super().__init__("战斗佣兵")
  181. self.add_strengh = add_strengh
  182. def run(self):
  183. basic_operate.go_outside()
  184. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  185. if self.add_strengh:
  186. basic_operate.add_strength()
  187. basic_operate.go_outside()
  188. else:
  189. print("没有足够的体力了")
  190. return False
  191. if waitClickImg_noWait_withBool(check_img.yongbing, 2, 1) == False:
  192. return False
  193. if waitClickImg_noWait_withBool(check_img.detect, 2, 1) == False:
  194. return False
  195. if waitClickImg_noWait_withBool(check_img.yongbing_fight, 2, 1) == False:
  196. return False
  197. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  198. return False
  199. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  200. return False
  201. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  202. return False
  203. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  204. maxTryTimes = 3
  205. while maxTryTimes > 0:
  206. maxTryTimes -= 1
  207. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  208. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  209. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  210. break
  211. return True
  212. class task_fight_jina(dongri_task):
  213. def __init__(self, add_strengh):
  214. super().__init__("战斗吉娜")
  215. self.add_strengh = add_strengh
  216. def run(self):
  217. basic_operate.go_outside()
  218. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  219. if self.add_strengh:
  220. basic_operate.add_strength()
  221. basic_operate.go_outside()
  222. else:
  223. print("没有足够的体力了")
  224. return False
  225. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  226. return False
  227. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  228. return False
  229. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  230. return False
  231. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  232. return False
  233. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  234. return False
  235. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  236. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  237. return False
  238. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  239. return False
  240. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  241. return False
  242. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  243. maxTryTimes = 3
  244. while maxTryTimes > 0:
  245. maxTryTimes -= 1
  246. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  247. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  248. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  249. break
  250. return True
  251. class task_fightMonster(dongri_task):
  252. def __init__(self, add_strengh, fight_bigMonster, isSimple):
  253. self.add_strengh = add_strengh
  254. self.isSimple = isSimple
  255. if fight_bigMonster == True:
  256. super().__init__(f"战斗大怪物")
  257. self.monster = monster_img.bigMonster
  258. self.attack = monster_img.muti_team
  259. else:
  260. super().__init__(f"战斗小怪物")
  261. self.monster = monster_img.wolf
  262. self.attack = monster_img.attack
  263. def run(self):
  264. basic_operate.go_outside()
  265. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  266. if self.add_strengh:
  267. basic_operate.add_strength()
  268. basic_operate.go_outside()
  269. else:
  270. print("没有足够的体力了")
  271. return False
  272. if False == basic_operate.click_outside_search():
  273. return False
  274. if waitFindImg_withBool(monster_img.search, 2, 1):
  275. myTimeSleep_big()
  276. yys_dragAuto(monster_img.move_left)
  277. if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
  278. return False
  279. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  280. return False
  281. if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
  282. return False
  283. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  284. if not self.isSimple:
  285. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  286. return False
  287. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  288. return False
  289. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  290. return False
  291. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  292. maxTryTimes = 3
  293. while maxTryTimes > 0:
  294. maxTryTimes -= 1
  295. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  296. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  297. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  298. break
  299. return True
  300. class task_collect(dongri_task):
  301. def __init__(self, type = 0, isSimple = False, isAddStrenghth = False):
  302. self.isSimple = isSimple
  303. self.isAddStrenghth = isAddStrenghth
  304. if isinstance(type, (list, tuple)):
  305. typeArr = type
  306. type = typeArr[random.randint(0, len(typeArr) - 1)]
  307. elif type == 0:
  308. typeArr = [4,4,3,3,3,2,2,2,1,1]
  309. type = typeArr[random.randint(0, len(typeArr) - 1)]
  310. elif type == 5:
  311. typeArr = [2,1]
  312. type = typeArr[random.randint(0, len(typeArr) - 1)]
  313. if type == 1:
  314. self.type = monster_img.meat
  315. self.line = monster_img.line2
  316. super().__init__(f"采集肉")
  317. elif type == 2:
  318. self.type = monster_img.wood
  319. self.line = monster_img.line3
  320. super().__init__(f"采集木头")
  321. elif type == 3:
  322. self.type = monster_img.mine
  323. self.line = monster_img.line4
  324. super().__init__(f"采矿石")
  325. elif type == 4:
  326. self.type = monster_img.iron
  327. self.line = monster_img.line5
  328. super().__init__(f"采集铁矿石")
  329. if isSimple:
  330. self.line = None
  331. def run(self):
  332. basic_operate.go_outside()
  333. if False == basic_operate.click_outside_search():
  334. return False
  335. if self.isAddStrenghth and basic_operate.get_line_num() >= 5:
  336. return False
  337. if waitFindImg_withBool(monster_img.search, 2, 1):
  338. myTimeSleep_big()
  339. yys_dragAuto(monster_img.move_right)
  340. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  341. return False
  342. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  343. return False
  344. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  345. return False
  346. if self.line != None:
  347. waitClickImg_noWait_withBool(self.line, 2, 1)
  348. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  349. return False
  350. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  351. maxTryTimes = 3
  352. while maxTryTimes > 0:
  353. maxTryTimes -= 1
  354. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  355. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  356. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  357. break
  358. return True
  359. class task_train(dongri_task):
  360. def __init__(self, force_lv1 = False):
  361. super().__init__(f"检查训练")
  362. self.force_lv1 = force_lv1
  363. def run(self):
  364. basic_operate.go_town()
  365. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  366. return False
  367. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  368. return False
  369. tryTimes = 3
  370. while tryTimes > 0:
  371. tryTimes -= 1
  372. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  373. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  374. break
  375. if self.force_lv1:
  376. myTimeSleep_big()
  377. yys_dragAuto(train_img.move_left)
  378. yys_dragAuto(train_img.move_left)
  379. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  380. return basic_operate.enter_auto_supply_resource(train_img.begin_train)
  381. class task_checkHelp(dongri_task):
  382. def __init__(self, isOutSide = False):
  383. super().__init__(f"检查帮助")
  384. self.isOutSide = isOutSide
  385. def run(self):
  386. if self.isOutSide:
  387. basic_operate.go_outside()
  388. else:
  389. basic_operate.go_town()
  390. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  391. return True
  392. class task_checkStoreRoom(dongri_task):
  393. def __init__(self):
  394. super().__init__(f"检查仓库或招募")
  395. def run(self):
  396. basic_operate.go_town()
  397. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  398. return False
  399. myTimeSleep_big()
  400. yys_dragAuto(check_img.move_down)
  401. yys_dragAuto(check_img.move_down)
  402. myTimeSleep_big()
  403. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  404. return False
  405. myTimeSleep_big()
  406. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
  407. pcacc_mouse.quickclick_current()
  408. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  409. return False
  410. pcacc_mouse.quickclick_current()
  411. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  412. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  413. else:
  414. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  415. dstPos = get_yys_random_point(check_img.pet_getRegion)
  416. pcacc_mouse.click(dstPos[0], dstPos[1])
  417. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  418. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  419. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  420. return True
  421. class task_checkConfilits(dongri_task):
  422. def __init__(self):
  423. super().__init__(f"检查集结")
  424. def run(self):
  425. basic_operate.go_outside()
  426. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  427. return False
  428. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  429. return False
  430. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  431. return False
  432. return True
  433. class task_checkDonata(dongri_task):
  434. def __init__(self):
  435. super().__init__(f"检查捐献")
  436. def run(self):
  437. basic_operate.go_town()
  438. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  439. return False
  440. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  441. return False
  442. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  443. return False
  444. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  445. return False
  446. else:
  447. maxTryTimes = 3
  448. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  449. maxTryTimes -= 1
  450. return True
  451. class task_checkAdventure(dongri_task):
  452. def __init__(self):
  453. super().__init__(f"检查冒险")
  454. def run(self):
  455. basic_operate.go_town()
  456. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  457. return False
  458. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  459. return False
  460. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  461. return False
  462. return True
  463. class task_waitTime(dongri_task):
  464. def __init__(self):
  465. super().__init__(f"等待时间")
  466. def run(self):
  467. myTimeSleep(300)
  468. class check_buildOrResearch(dongri_task):
  469. def __init__(self):
  470. super().__init__(f"检查建筑或研究")
  471. def run(self):
  472. basic_operate.go_town()
  473. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  474. return False
  475. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  476. return False
  477. dstType = 'none'
  478. while True:
  479. 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):
  480. dstType = 'build'
  481. break
  482. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  483. if not handRet:
  484. return False
  485. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  486. dstPos = [0, 0]
  487. if not detailRet:
  488. # 如果找不到详细信息,兵营之类的,需点中间
  489. dstPos = [handPos[0] - 70, handPos[1] + 120]
  490. else:
  491. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  492. tryTimes = 5
  493. while tryTimes > 0:
  494. tryTimes -= 1
  495. myTimeSleep_big()
  496. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  497. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  498. dstType = 'research'
  499. break
  500. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  501. dstType = 'build'
  502. break
  503. break
  504. if dstType == 'none':
  505. print('没有找到建筑或研究')
  506. return False
  507. elif dstType == 'build':
  508. buildtimes = 4
  509. 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]):
  510. buildtimes -= 1
  511. if buildtimes == 0:
  512. break
  513. continue
  514. elif dstType == 'research':
  515. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  516. return False
  517. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  518. return False
  519. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  520. return True
  521. class task_information(dongri_task):
  522. def __init__(self):
  523. super().__init__(f"检查情报")
  524. def run(self):
  525. basic_operate.go_outside()
  526. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  527. return False
  528. if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 0.5, 0.5):
  529. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  530. return False
  531. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  532. return False
  533. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  534. waitClickImg_noWait(information_img.add_strength, 1, 1)
  535. waitClickImg_noWait(information_img.add_strength, 1, 1)
  536. waitClickImg_noWait(information_img.add_strength, 1, 1)
  537. return False
  538. myTimeSleep_big()
  539. return True
  540. elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 0.5, 0.5):
  541. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  542. return False
  543. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  544. return False
  545. waitClickImg_noWait(information_img.add_strength, 1, 1)
  546. waitClickImg_noWait(information_img.add_strength, 1, 1)
  547. waitClickImg_noWait(information_img.add_strength, 1, 1)
  548. return True
  549. elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 0.5, 0.5):
  550. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  551. return False
  552. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  553. return False
  554. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  555. return False
  556. if waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1) == False:
  557. return False
  558. waitClickImg_noWait(information_img.add_strength, 1, 1)
  559. waitClickImg_noWait(information_img.add_strength, 1, 1)
  560. waitClickImg_noWait(information_img.add_strength, 1, 1)
  561. return True
  562. else:
  563. return False
  564. class task_returnAllLine(dongri_task):
  565. def __init__(self):
  566. super().__init__(f"返回所有路线")
  567. def run(self):
  568. basic_operate.go_outside()
  569. basic_operate.return_line()
  570. basic_operate.return_line()
  571. basic_operate.return_line()
  572. basic_operate.return_line()
  573. basic_operate.return_line()
  574. basic_operate.return_line()
  575. return True
  576. class task_paticipateInTeam(dongri_task):
  577. def __init__(self):
  578. super().__init__(f"参与队伍")
  579. def run(self):
  580. basic_operate.go_outside()
  581. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  582. return False
  583. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
  584. return False
  585. while True:
  586. if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
  587. break
  588. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  589. break
  590. if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
  591. break
  592. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  593. break
  594. break
  595. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  596. return False
  597. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  598. maxTryTimes = 3
  599. while maxTryTimes > 0:
  600. maxTryTimes -= 1
  601. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  602. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  603. break
  604. return True
  605. class task_cure(dongri_task):
  606. def __init__(self):
  607. super().__init__(f"治疗")
  608. def run(self):
  609. basic_operate.go_outside()
  610. if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  611. return False
  612. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  613. return False
  614. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  615. return False
  616. return True
  617. class task_useAnnimalSkill(dongri_task):
  618. def __init__(self):
  619. super().__init__(f"使用动物技能")
  620. def run(self):
  621. basic_operate.go_outside()
  622. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  623. return False
  624. if waitClickImg_noWait_withBool(check_img.wolf_skill, 2, 1) == False:
  625. return False
  626. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  627. return False
  628. class task_activity_lianmeng(dongri_task):
  629. def __init__(self):
  630. super().__init__(f"联盟总动员")
  631. def run(self):
  632. basic_operate.go_town()
  633. if waitClickImg_noWait_withBool(special_activity_img.normal, 2, 1) == False:
  634. return False
  635. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2), 2, 1) == False:
  636. return False
  637. waitClickImg_noWait_withBool(special_activity_img.task_done, 2, 1)
  638. if waitFindImg_withBool(special_activity_img.doing_task, 2, 1) == False:
  639. if waitClickImg_noWait_withBool((special_activity_img.shili_120), 2, 1) == True:
  640. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  641. return False
  642. if waitFindImg_withBool(special_activity_img.shili, 2, 1) == False:
  643. maxTryTimes = 2
  644. while waitClickImg_noWait_withBool(special_activity_img.owning, 2, 1) == True:
  645. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  646. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  647. maxTryTimes -= 1
  648. if maxTryTimes <= 0:
  649. break
  650. return True
  651. if __name__ == '__main__':
  652. #basic_operate.get_line_num()
  653. #yys_ocrAuto(check_img.line_orc)
  654. #basic_operate.go_town()
  655. #basic_operate.add_strength()
  656. #task_fightMonster(False, True).run()
  657. #task_checkHelp().run()
  658. task_checkStoreRoom().run()
  659. #task_activity_lianmeng().run()
  660. #task_fight_yongbing(True).run()
  661. #task_collect([4,3,2,1]).run()
  662. #task_train().run()
  663. #task_information().run()
  664. #check_buildOrResearch().run()
  665. #task_checkDonata().run()
  666. #task_collect(1).run()
  667. #task_collect(2).run()
  668. #task_collect(3).run()
  669. #task_collect(4).run()
  670. #task_returnAllLine().run()
  671. #task_paticipateInTeam().run()
  672. #task_fight_jina(True).run()