dongri_task.py 32 KB

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