dongri_task.py 30 KB

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