dongri_task.py 31 KB

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