dongri_task.py 36 KB

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