dongri_task.py 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  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] + 80, 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. if isSimple:
  344. self.line = None
  345. def run(self):
  346. basic_operate.go_outside()
  347. if False == basic_operate.click_outside_search():
  348. return False
  349. if self.isAddStrenghth and basic_operate.get_line_num() >= 5:
  350. return False
  351. if waitFindImg_withBool(monster_img.search, 2, 1):
  352. myTimeSleep_big()
  353. yys_dragAuto(monster_img.move_right)
  354. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  355. return False
  356. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  357. return False
  358. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  359. return False
  360. if self.line != None:
  361. waitClickImg_noWait_withBool(self.line, 2, 1)
  362. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  363. return False
  364. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  365. maxTryTimes = 3
  366. while maxTryTimes > 0:
  367. maxTryTimes -= 1
  368. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  369. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  370. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  371. break
  372. return True
  373. class task_train(dongri_task):
  374. def __init__(self, train_type = None):
  375. super().__init__(f"检查训练{train_type}")
  376. self.train_type = train_type
  377. def run(self):
  378. basic_operate.go_town()
  379. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  380. return False
  381. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  382. return False
  383. tryTimes = 3
  384. while tryTimes > 0:
  385. tryTimes -= 1
  386. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  387. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  388. break
  389. if self.train_type == 'lv1':
  390. myTimeSleep_big()
  391. yys_dragAuto(train_img.move_left)
  392. yys_dragAuto(train_img.move_left)
  393. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  394. elif self.train_type == 'lv8':
  395. waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
  396. elif self.train_type == 'lv9':
  397. waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
  398. return basic_operate.enter_auto_supply_resource(train_img.begin_train)
  399. class task_checkHelp(dongri_task):
  400. def __init__(self, isOutSide = False):
  401. super().__init__(f"检查帮助")
  402. self.isOutSide = isOutSide
  403. def run(self):
  404. if self.isOutSide:
  405. basic_operate.go_outside()
  406. else:
  407. basic_operate.go_town()
  408. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  409. return True
  410. class task_checkStoreRoom(dongri_task):
  411. def __init__(self):
  412. super().__init__(f"检查仓库或招募")
  413. def run(self):
  414. basic_operate.go_town()
  415. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  416. return False
  417. myTimeSleep_big()
  418. yys_dragAuto(check_img.move_down)
  419. yys_dragAuto(check_img.move_down)
  420. myTimeSleep_big()
  421. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  422. return False
  423. myTimeSleep_big()
  424. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
  425. pcacc_mouse.quickclick_current()
  426. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  427. return False
  428. pcacc_mouse.quickclick_current()
  429. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  430. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  431. else:
  432. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  433. dstPos = get_yys_random_point(check_img.pet_getRegion)
  434. pcacc_mouse.click(dstPos[0], dstPos[1])
  435. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  436. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  437. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  438. return True
  439. class task_checkConfilits(dongri_task):
  440. def __init__(self):
  441. super().__init__(f"检查集结")
  442. def run(self):
  443. basic_operate.go_outside()
  444. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  445. return False
  446. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  447. return False
  448. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  449. return False
  450. return True
  451. class task_checkDonata(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.union, 2, 1) == False:
  457. return False
  458. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  459. return False
  460. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  461. return False
  462. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  463. return False
  464. else:
  465. maxTryTimes = 3
  466. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  467. maxTryTimes -= 1
  468. return True
  469. class task_checkAdventure(dongri_task):
  470. def __init__(self):
  471. super().__init__(f"检查冒险")
  472. def run(self):
  473. basic_operate.go_town()
  474. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  475. return False
  476. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  477. return False
  478. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  479. return False
  480. return True
  481. class task_waitTime(dongri_task):
  482. def __init__(self):
  483. super().__init__(f"等待时间")
  484. def run(self):
  485. myTimeSleep(300)
  486. class check_buildOrResearch(dongri_task):
  487. def __init__(self):
  488. super().__init__(f"检查建筑或研究")
  489. def run(self):
  490. basic_operate.go_town()
  491. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  492. return False
  493. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  494. return False
  495. dstType = 'none'
  496. while True:
  497. 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):
  498. dstType = 'build'
  499. break
  500. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  501. if not handRet:
  502. return False
  503. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  504. dstPos = [0, 0]
  505. if not detailRet:
  506. # 如果找不到详细信息,兵营之类的,需点中间
  507. dstPos = [handPos[0] - 70, handPos[1] + 120]
  508. else:
  509. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  510. tryTimes = 5
  511. while tryTimes > 0:
  512. tryTimes -= 1
  513. myTimeSleep_big()
  514. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  515. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  516. dstType = 'research'
  517. break
  518. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  519. dstType = 'build'
  520. break
  521. break
  522. if dstType == 'none':
  523. print('没有找到建筑或研究')
  524. return False
  525. elif dstType == 'build':
  526. buildtimes = 4
  527. 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]):
  528. buildtimes -= 1
  529. if buildtimes == 0:
  530. break
  531. continue
  532. elif dstType == 'research':
  533. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  534. return False
  535. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  536. return False
  537. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  538. return True
  539. class task_information(dongri_task):
  540. def __init__(self):
  541. super().__init__(f"检查情报")
  542. def run(self):
  543. basic_operate.go_outside()
  544. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  545. return False
  546. if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 0.5, 0.5):
  547. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  548. return False
  549. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  550. return False
  551. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  552. waitClickImg_noWait(information_img.add_strength, 1, 1)
  553. waitClickImg_noWait(information_img.add_strength, 1, 1)
  554. waitClickImg_noWait(information_img.add_strength, 1, 1)
  555. return False
  556. myTimeSleep_big()
  557. return True
  558. elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 0.5, 0.5):
  559. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  560. return False
  561. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  562. return False
  563. waitClickImg_noWait(information_img.add_strength, 1, 1)
  564. waitClickImg_noWait(information_img.add_strength, 1, 1)
  565. waitClickImg_noWait(information_img.add_strength, 1, 1)
  566. return True
  567. elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 0.5, 0.5):
  568. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  569. return False
  570. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  571. return False
  572. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  573. return False
  574. if waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1) == False:
  575. return False
  576. waitClickImg_noWait(information_img.add_strength, 1, 1)
  577. waitClickImg_noWait(information_img.add_strength, 1, 1)
  578. waitClickImg_noWait(information_img.add_strength, 1, 1)
  579. return True
  580. else:
  581. return False
  582. class task_returnAllLine(dongri_task):
  583. def __init__(self):
  584. super().__init__(f"返回所有路线")
  585. def run(self):
  586. basic_operate.go_outside()
  587. basic_operate.return_line()
  588. basic_operate.return_line()
  589. basic_operate.return_line()
  590. basic_operate.return_line()
  591. basic_operate.return_line()
  592. basic_operate.return_line()
  593. return True
  594. class task_paticipateInTeam(dongri_task):
  595. def __init__(self):
  596. super().__init__(f"参与队伍")
  597. def run(self):
  598. basic_operate.go_outside()
  599. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  600. return False
  601. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
  602. return False
  603. while True:
  604. if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
  605. break
  606. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  607. break
  608. if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
  609. break
  610. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  611. break
  612. break
  613. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  614. return False
  615. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  616. maxTryTimes = 3
  617. while maxTryTimes > 0:
  618. maxTryTimes -= 1
  619. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  620. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  621. break
  622. return True
  623. class task_cure(dongri_task):
  624. def __init__(self):
  625. super().__init__(f"治疗")
  626. def run(self):
  627. basic_operate.go_outside()
  628. if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  629. return False
  630. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  631. return False
  632. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  633. return False
  634. return True
  635. class task_useAnnimalSkill(dongri_task):
  636. def __init__(self):
  637. super().__init__(f"使用动物技能")
  638. def run(self):
  639. basic_operate.go_outside()
  640. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  641. return False
  642. if waitClickImg_noWait_withBool(check_img.wolf_skill, 2, 1) == False:
  643. return False
  644. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  645. return False
  646. class task_activity_lianmeng(dongri_task):
  647. def __init__(self):
  648. super().__init__(f"联盟总动员")
  649. def run(self):
  650. basic_operate.go_town()
  651. if waitClickImg_noWait_withBool(special_activity_img.normal, 2, 1) == False:
  652. return False
  653. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2), 2, 1) == False:
  654. return False
  655. waitClickImg_noWait_withBool(special_activity_img.task_done, 2, 1)
  656. if waitFindImg_withBool(special_activity_img.doing_task, 2, 1) == False:
  657. if waitClickImg_noWait_withBool((special_activity_img.shili_120), 2, 1) == True:
  658. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  659. return False
  660. if waitFindImg_withBool(special_activity_img.shili, 2, 1) == False:
  661. maxTryTimes = 2
  662. while waitClickImg_noWait_withBool(special_activity_img.owning, 2, 1) == True:
  663. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  664. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  665. maxTryTimes -= 1
  666. if maxTryTimes <= 0:
  667. break
  668. return True
  669. class task_checkMaster(dongri_task):
  670. def __init__(self):
  671. super().__init__(f"检查统帅")
  672. def run(self):
  673. basic_operate.go_town()
  674. if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
  675. return False
  676. if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
  677. return False
  678. myTimeSleep_big()
  679. pcacc_mouse.quickclick_current()
  680. if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
  681. return False
  682. return True
  683. class task_checkActivities(dongri_task):
  684. def __init__(self):
  685. super().__init__(f"检查各种活动时间")
  686. def find_all_matching_events(parts, input_word):
  687. results = []
  688. # 查找所有包含输入关键词的项
  689. matches = [i for i, part in enumerate(parts) if input_word in part]
  690. for match_index in matches:
  691. # 从匹配项开始向后查找第一个时间或状态
  692. for i in range(match_index + 1, len(parts)):
  693. current_part = parts[i]
  694. # 检查是否是时间(如 19:30)或状态(如 已结束)
  695. if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
  696. dst = {"item":parts[match_index], "time":current_part}
  697. results.append(dst)
  698. break # 找到第一个匹配就停止
  699. return results
  700. def run(self):
  701. global todo_msg, todo_list
  702. basic_operate.go_outside()
  703. if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
  704. return False
  705. if waitFindImg_withBool(check_img.todoList, 2, 1) == False:
  706. return False
  707. activityStr = yys_ocrAuto(check_img.todo_region)
  708. if activityStr:
  709. todo_msg = activityStr
  710. result = []
  711. baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
  712. result.extend(baoleiArr)
  713. juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
  714. result.extend(juxiongArr)
  715. yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
  716. result.extend(yaosaiArr)
  717. todo_list = result
  718. return activityStr
  719. if __name__ == '__main__':
  720. task_checkActivities().run()
  721. #task_checkMaster().run()
  722. #basic_operate.get_line_num()
  723. #yys_ocrAuto(check_img.line_orc)
  724. #basic_operate.go_town()
  725. #basic_operate.add_strength()
  726. #task_fightMonster(False, True).run()
  727. #task_checkHelp().run()
  728. #task_checkStoreRoom().run()
  729. #task_activity_lianmeng().run()
  730. #task_fight_yongbing(True).run()
  731. #task_collect([4,3,2,1]).run()
  732. #task_train().run()
  733. #task_information().run()
  734. #check_buildOrResearch().run()
  735. #task_checkDonata().run()
  736. #task_collect(1).run()
  737. #task_collect(2).run()
  738. #task_collect(3).run()
  739. #task_collect(4).run()
  740. #task_returnAllLine().run()
  741. #task_paticipateInTeam().run()
  742. #task_fight_jina(True).run()