dongri_task.py 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  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_call_jina(dongri_task):
  225. def __init__(self):
  226. super().__init__("召唤吉娜")
  227. def run(self):
  228. basic_operate.go_outside()
  229. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  230. return False
  231. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  232. return False
  233. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  234. return False
  235. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  236. return False
  237. if waitClickImg_noWait_withBool(check_img.share, 2, 1) == False:
  238. return False
  239. if waitClickImg_noWait_withBool(check_img.to_pcacc, 2, 1) == False:
  240. return False
  241. if waitClickImg_noWait_withBool(check_img.share_btn, 2, 1) == False:
  242. return False
  243. return True
  244. class task_fight_jina(dongri_task):
  245. def __init__(self, add_strengh):
  246. super().__init__("战斗吉娜")
  247. self.add_strengh = add_strengh
  248. def run(self):
  249. basic_operate.go_outside()
  250. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  251. if self.add_strengh:
  252. basic_operate.add_strength()
  253. basic_operate.go_outside()
  254. else:
  255. print("没有足够的体力了")
  256. return False
  257. if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
  258. return False
  259. if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
  260. return False
  261. if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
  262. return False
  263. if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
  264. return False
  265. if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
  266. return False
  267. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  268. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  269. return False
  270. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  271. return False
  272. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  273. return False
  274. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  275. maxTryTimes = 3
  276. while maxTryTimes > 0:
  277. maxTryTimes -= 1
  278. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  279. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  280. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  281. break
  282. return True
  283. class task_fightMonster(dongri_task):
  284. def __init__(self, add_strengh, fight_bigMonster, isSimple):
  285. self.add_strengh = add_strengh
  286. self.isSimple = isSimple
  287. if fight_bigMonster == True:
  288. super().__init__(f"战斗大怪物")
  289. self.monster = monster_img.bigMonster
  290. self.attack = monster_img.muti_team
  291. else:
  292. super().__init__(f"战斗小怪物")
  293. self.monster = monster_img.wolf
  294. self.attack = monster_img.attack
  295. def run(self):
  296. basic_operate.go_outside()
  297. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  298. if self.add_strengh:
  299. basic_operate.add_strength()
  300. basic_operate.go_outside()
  301. else:
  302. print("没有足够的体力了")
  303. return False
  304. if False == basic_operate.click_outside_search():
  305. return False
  306. if self.add_strengh and basic_operate.get_line_num() >= 6:
  307. return False
  308. if waitFindImg_withBool(monster_img.search, 2, 1):
  309. myTimeSleep_big()
  310. yys_dragAuto(monster_img.move_left)
  311. if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
  312. return False
  313. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  314. return False
  315. if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
  316. return False
  317. waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
  318. if not self.isSimple:
  319. if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
  320. return False
  321. if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
  322. return False
  323. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  324. return False
  325. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  326. maxTryTimes = 3
  327. while maxTryTimes > 0:
  328. maxTryTimes -= 1
  329. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  330. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  331. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  332. break
  333. return True
  334. class task_collect(dongri_task):
  335. def __init__(self, type = 0, isSimple = False, isAddStrenghth = False):
  336. self.isSimple = isSimple
  337. self.isAddStrenghth = isAddStrenghth
  338. if isinstance(type, (list, tuple)):
  339. typeArr = type
  340. type = typeArr[random.randint(0, len(typeArr) - 1)]
  341. elif type == 0:
  342. typeArr = [4,4,3,3,3,2,2,2,1,1]
  343. type = typeArr[random.randint(0, len(typeArr) - 1)]
  344. elif type == 5:
  345. typeArr = [2,1]
  346. type = typeArr[random.randint(0, len(typeArr) - 1)]
  347. if type == 1:
  348. self.type = monster_img.meat
  349. self.line = monster_img.line2
  350. super().__init__(f"采集肉")
  351. elif type == 2:
  352. self.type = monster_img.wood
  353. self.line = monster_img.line3
  354. super().__init__(f"采集木头")
  355. elif type == 3:
  356. self.type = monster_img.mine
  357. self.line = monster_img.line4
  358. super().__init__(f"采矿石")
  359. elif type == 4:
  360. self.type = monster_img.iron
  361. self.line = monster_img.line5
  362. super().__init__(f"采集铁矿石")
  363. else:
  364. self.type = None
  365. self.line = None
  366. super().__init__(f"采集None")
  367. if isSimple:
  368. self.line = None
  369. def run(self):
  370. if self.type == None:
  371. return True
  372. basic_operate.go_outside()
  373. if False == basic_operate.click_outside_search():
  374. return False
  375. if self.isAddStrenghth and basic_operate.get_line_num() >= 5:
  376. return False
  377. if waitFindImg_withBool(monster_img.search, 2, 1):
  378. myTimeSleep_big()
  379. yys_dragAuto(monster_img.move_right)
  380. if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
  381. return False
  382. if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
  383. return False
  384. if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
  385. return False
  386. if self.line != None:
  387. waitClickImg_noWait_withBool(self.line, 2, 1)
  388. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  389. return False
  390. waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
  391. maxTryTimes = 3
  392. while maxTryTimes > 0:
  393. maxTryTimes -= 1
  394. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  395. waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
  396. if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
  397. break
  398. return True
  399. class task_train(dongri_task):
  400. def __init__(self, train_type = None):
  401. super().__init__(f"检查训练{train_type}")
  402. self.train_type = train_type
  403. def run(self):
  404. basic_operate.go_town()
  405. if self.train_type == 'None':
  406. return True
  407. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  408. return False
  409. if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
  410. return False
  411. tryTimes = 3
  412. while tryTimes > 0:
  413. tryTimes -= 1
  414. waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
  415. if waitClickImg_noWait_withBool(train_img.train, 2, 1):
  416. break
  417. if self.train_type == 'lv1':
  418. myTimeSleep_big()
  419. yys_dragAuto(train_img.move_left)
  420. yys_dragAuto(train_img.move_left)
  421. waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
  422. elif self.train_type == 'lv8':
  423. waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
  424. elif self.train_type == 'lv9':
  425. waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
  426. return basic_operate.enter_auto_supply_resource(train_img.begin_train)
  427. class task_checkHelp(dongri_task):
  428. def __init__(self, isOutSide = False):
  429. super().__init__(f"检查帮助")
  430. self.isOutSide = isOutSide
  431. def run(self):
  432. if self.isOutSide:
  433. basic_operate.go_outside()
  434. else:
  435. basic_operate.go_town()
  436. waitClickImg_noWait_withBool(place_img.help, 2, 1)
  437. return True
  438. class task_checkStoreRoom(dongri_task):
  439. def __init__(self):
  440. super().__init__(f"检查仓库或招募")
  441. def run(self):
  442. basic_operate.go_town()
  443. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  444. return False
  445. myTimeSleep_big()
  446. yys_dragAuto(check_img.move_down)
  447. yys_dragAuto(check_img.move_down)
  448. myTimeSleep_big()
  449. if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
  450. return False
  451. myTimeSleep_big()
  452. if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
  453. pcacc_mouse.quickclick_current()
  454. waitClickImg_noWait_withBool((check_img.detail,check_img.detail2), 2, 1)
  455. basic_operate.go_town()
  456. if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
  457. return False
  458. myTimeSleep_big()
  459. pcacc_mouse.quickclick_current()
  460. myTimeSleep_big()
  461. waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
  462. waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
  463. else:
  464. if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
  465. myTimeSleep_big()
  466. dstPos = get_yys_random_point(check_img.pet_getRegion)
  467. pcacc_mouse.click(dstPos[0], dstPos[1])
  468. myTimeSleep_big()
  469. elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
  470. waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
  471. waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
  472. return True
  473. class task_checkConfilits(dongri_task):
  474. def __init__(self):
  475. super().__init__(f"检查集结")
  476. def run(self):
  477. basic_operate.go_outside()
  478. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  479. return False
  480. if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
  481. return False
  482. if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
  483. return False
  484. return True
  485. class task_checkDonata(dongri_task):
  486. def __init__(self):
  487. super().__init__(f"检查捐献")
  488. def run(self):
  489. basic_operate.go_town()
  490. if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
  491. return False
  492. if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
  493. return False
  494. if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
  495. return False
  496. if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
  497. return False
  498. else:
  499. maxTryTimes = 3
  500. while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
  501. maxTryTimes -= 1
  502. return True
  503. class task_checkAdventure(dongri_task):
  504. def __init__(self):
  505. super().__init__(f"检查冒险")
  506. def run(self):
  507. basic_operate.go_town()
  508. if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
  509. return False
  510. if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
  511. return False
  512. if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
  513. return False
  514. return True
  515. class task_waitTime(dongri_task):
  516. def __init__(self):
  517. super().__init__(f"等待时间")
  518. def run(self):
  519. myTimeSleep(300)
  520. class check_buildOrResearch(dongri_task):
  521. def __init__(self):
  522. super().__init__(f"检查建筑或研究")
  523. def run(self):
  524. basic_operate.go_town()
  525. if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
  526. return False
  527. if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
  528. return False
  529. dstType = 'none'
  530. while True:
  531. 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):
  532. dstType = 'build'
  533. break
  534. handRet, handPos = waitFindImg(check_img.hand, 2, 1)
  535. if not handRet:
  536. return False
  537. detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
  538. dstPos = [0, 0]
  539. if not detailRet:
  540. # 如果找不到详细信息,兵营之类的,需点中间
  541. dstPos = [handPos[0] - 70, handPos[1] + 120]
  542. else:
  543. dstPos = [detailPos[0] + 70, detailPos[1] - 100]
  544. tryTimes = 5
  545. while tryTimes > 0:
  546. tryTimes -= 1
  547. myTimeSleep_big()
  548. pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
  549. if waitClickImg_noWait_withBool(check_img.research, 2, 1):
  550. dstType = 'research'
  551. break
  552. elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
  553. dstType = 'build'
  554. break
  555. break
  556. if dstType == 'none':
  557. print('没有找到建筑或研究')
  558. return False
  559. elif dstType == 'build':
  560. buildtimes = 4
  561. 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]):
  562. buildtimes -= 1
  563. if buildtimes == 0:
  564. break
  565. continue
  566. elif dstType == 'research':
  567. if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
  568. return False
  569. if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
  570. return False
  571. waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
  572. return True
  573. class task_information(dongri_task):
  574. def __init__(self, isAddStrengh = False):
  575. super().__init__(f"检查情报")
  576. self.isAddStrengh = isAddStrengh
  577. def run(self):
  578. basic_operate.go_outside()
  579. if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
  580. if self.isAddStrengh:
  581. basic_operate.add_strength()
  582. basic_operate.go_outside()
  583. else:
  584. print("没有足够的体力了")
  585. return False
  586. if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
  587. return False
  588. if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 0.5, 0.5):
  589. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  590. return False
  591. if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
  592. return False
  593. if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
  594. return False
  595. myTimeSleep_big()
  596. return True
  597. elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 0.5, 0.5):
  598. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  599. return False
  600. if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
  601. return False
  602. return True
  603. elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 0.5, 0.5):
  604. if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
  605. return False
  606. if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
  607. return False
  608. if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
  609. return False
  610. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  611. return False
  612. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  613. maxTryTimes = 3
  614. while maxTryTimes > 0:
  615. maxTryTimes -= 1
  616. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  617. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  618. break
  619. return True
  620. else:
  621. return False
  622. class task_returnAllLine(dongri_task):
  623. def __init__(self):
  624. super().__init__(f"返回所有路线")
  625. def run(self):
  626. basic_operate.go_outside()
  627. basic_operate.return_line()
  628. basic_operate.return_line()
  629. basic_operate.return_line()
  630. basic_operate.return_line()
  631. basic_operate.return_line()
  632. basic_operate.return_line()
  633. return True
  634. class task_paticipateInTeam(dongri_task):
  635. def __init__(self):
  636. super().__init__(f"参与队伍")
  637. def run(self):
  638. basic_operate.go_outside()
  639. if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
  640. return False
  641. if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
  642. return False
  643. while True:
  644. if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
  645. break
  646. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  647. break
  648. if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
  649. break
  650. if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
  651. break
  652. break
  653. if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
  654. return False
  655. waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
  656. maxTryTimes = 3
  657. while maxTryTimes > 0:
  658. maxTryTimes -= 1
  659. waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
  660. if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
  661. break
  662. return True
  663. class task_cure(dongri_task):
  664. def __init__(self, continueCure = False, cureNum = None):
  665. super().__init__(f"治疗")
  666. self.continueCure = continueCure
  667. self.cureNum = cureNum
  668. def run(self):
  669. basic_operate.go_outside()
  670. if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
  671. return False
  672. if self.continueCure == False:
  673. if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
  674. return False
  675. if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
  676. return False
  677. else:
  678. maxTryTimes = 50
  679. while waitClickImg_noWait_withBool((check_img.cure, check_img.help4), 30, 1) and maxTryTimes >= 0:
  680. maxTryTimes -= 1
  681. continue
  682. return True
  683. class task_useAnnimalSkill(dongri_task):
  684. def __init__(self):
  685. super().__init__(f"使用动物技能")
  686. def run(self):
  687. basic_operate.go_outside()
  688. if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
  689. return False
  690. if waitClickImg_noWait_withBool((check_img.wolf_skill, check_img.elephant_skill), 2, 1) == False:
  691. return False
  692. if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
  693. return False
  694. class task_activity_lianmeng(dongri_task):
  695. def __init__(self):
  696. super().__init__(f"联盟总动员")
  697. def run(self):
  698. basic_operate.go_town()
  699. if waitClickImg_noWait_withBool(special_activity_img.normal, 2, 1) == False:
  700. return False
  701. if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2), 2, 1) == False:
  702. return False
  703. waitClickImg_noWait_withBool(special_activity_img.task_done, 2, 1)
  704. if waitFindImg_withBool(special_activity_img.doing_task, 2, 1) == False:
  705. if waitClickImg_noWait_withBool((special_activity_img.shili_120, special_activity_img.shili_860), 2, 1) == True:
  706. if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
  707. return False
  708. if waitFindImg_withBool((special_activity_img.shili_120, special_activity_img.shili_860), 2, 1) == False:
  709. maxTryTimes = 2
  710. while waitClickImg_noWait_withBool((special_activity_img.owning, special_activity_img.owning_120), 2, 1) == True:
  711. waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
  712. waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
  713. maxTryTimes -= 1
  714. if maxTryTimes <= 0:
  715. break
  716. return True
  717. class task_checkMaster(dongri_task):
  718. def __init__(self):
  719. super().__init__(f"检查统帅")
  720. def run(self):
  721. basic_operate.go_town()
  722. if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
  723. return False
  724. if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
  725. return False
  726. myTimeSleep_big()
  727. pcacc_mouse.quickclick_current()
  728. if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
  729. return False
  730. return True
  731. class task_checkActivities(dongri_task):
  732. def __init__(self):
  733. super().__init__(f"检查各种活动时间")
  734. def find_all_matching_events(parts, input_word):
  735. results = []
  736. # 查找所有包含输入关键词的项
  737. matches = [i for i, part in enumerate(parts) if input_word in part]
  738. for match_index in matches:
  739. # 从匹配项开始向后查找第一个时间或状态
  740. for i in range(match_index + 1, len(parts)):
  741. current_part = parts[i]
  742. # 检查是否是时间(如 19:30)或状态(如 已结束)
  743. if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
  744. dst = {"item":parts[match_index], "time":current_part}
  745. results.append(dst)
  746. break # 找到第一个匹配就停止
  747. return results
  748. def run(self):
  749. global todo_msg, todo_list
  750. basic_operate.go_outside()
  751. if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
  752. return False
  753. if waitFindImg_withBool(check_img.todoList, 2, 1) == False:
  754. return False
  755. activityStr = yys_ocrAuto(check_img.todo_region)
  756. if activityStr:
  757. todo_msg = activityStr
  758. print(todo_msg)
  759. result = []
  760. '''
  761. ['北京时间', '2025-04-01', '据点争夺', '07:00', '3级科技工程站']
  762. judianArr = self.find_all_matching_events(activityStr, "据点")
  763. result.extend(judianArr)
  764. baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
  765. result.extend(baoleiArr)
  766. juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
  767. result.extend(juxiongArr)
  768. yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
  769. result.extend(yaosaiArr)
  770. todo_list = result
  771. '''
  772. return activityStr
  773. if __name__ == '__main__':
  774. task_call_jina().run()
  775. #task_checkConfilits().run()
  776. #task_checkActivities().run()
  777. #task_checkMaster().run()
  778. #basic_operate.get_line_num()
  779. #yys_ocrAuto(check_img.line_orc)
  780. #basic_operate.go_town()
  781. #basic_operate.add_strength()
  782. #task_fightMonster(False, False,False).run()
  783. #task_checkHelp().run()
  784. #task_checkStoreRoom().run()
  785. #task_activity_lianmeng().run()
  786. #task_fight_yongbing(True).run()
  787. #task_collect([4,3,2,1]).run()
  788. #task_train("lv9").run()
  789. #task_information().run()
  790. #check_buildOrResearch().run()
  791. #task_checkDonata().run()
  792. #task_collect(1).run()
  793. #task_collect(2).run()
  794. #task_collect(3).run()
  795. #task_collect(4).run()
  796. #task_returnAllLine().run()
  797. #task_paticipateInTeam().run()
  798. #task_fight_jina(True).run()