1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006 |
- # -*- coding: utf-8 -*-
- import threading
- from scriptBase.imgFind import pcacc_img, savePic
- from scriptBase.mouseClick import pcacc_mouse
- from scriptBase.ocr import capture_and_ocr
- import scriptBase.base
- from scriptBase.comon import *
- from scriptBase.ocr import *
- from apscheduler.schedulers.blocking import BlockingScheduler
- import pyautogui
- import random
- import sys
- import math
- import os
- import time
- from dongri_define import *
- from dongri_pic import *
- import subprocess
- import socket
- from dongri_pic import _imported
- '''
- 基础配置说明:
- 600*800(DPI 300)
- 游戏画面:流畅
- 高帧率关闭
- 町中模式:旧版
- '''
- todo_msg = ''
- todo_list = []
- def get_todo_msg():
- global todo_msg
- return todo_msg
- def get_todo_msgList():
- global todo_list
- return todo_list
- def fing_todoList_time(taskStr):
- for item in todo_list:
- if item['task'] == taskStr:
- return item['time']
- def task_getComputerName():
- return socket.gethostname()
- def task_acceptTask():
- while True:
- myTimeSleep_big()
- def init():
- global _imported
- if not _imported:
- acceptTask = threading.Thread(target=task_acceptTask)
- acceptTask.daemon = True
- if acceptTask.is_alive() == False:
- acceptTask.start()
- _imported = True
- class basic_operate:
- @staticmethod
- def do_back():
- task_return_game()
- ret = False
- ret |= waitClickImg_noWait_withBool(place_img.back1, 0.6, 0)
- if ret:
- return
- ret |= waitClickImg_noWait_withBool(place_img.back2, 0.6, 0)
- if ret:
- return
- ret |= waitClickImg_noWait_withBool(place_img.back3, 0.6, 0)
- if ret:
- return
- ret, pos = waitFindImg(place_img.title, 1, 0)
- if ret:
- pcacc_mouse.click(pos[0] + 20, pos[1] + 80)
- def backToGame(preTime = 0):
- tryMaxTimes = 5
- while tryMaxTimes > 0:
- tryMaxTimes -= 1
- if waitFindImg_withBool(place_img.gameIn, 1, preTime) == False:
- basic_operate.do_back()
- else:
- return True
- return False
-
- @staticmethod
- def go_town(preTime = 0):
- if basic_operate.backToGame(preTime) == False:
- return False
- waitClickImg_noWait_withBool(place_img.outside, 0.6, 0)
- return True
-
- @staticmethod
- def go_outside(preTime = 0):
- if basic_operate.backToGame(preTime) == False:
- return False
- waitClickImg_noWait_withBool(place_img.town, 0.6, 0)
- return True
-
- @staticmethod
- def click_outside_search():
- taskListRet, taskListPos = waitFindImg(monster_img.tasklist, 2, 3)
- if taskListRet == False:
- return False
- else:
- pcacc_mouse.click(taskListPos[0], taskListPos[1] - 110)#click search
- myTimeSleep_big()
- return True
-
- @staticmethod
- def enter_auto_supply_resource(enter_pic):
- if waitClickImg_noWait_withBool(enter_pic, 2, 2) == False:
- return False
-
- if waitClickImg_noWait_withBool(train_img.getAll, 2, 1) == False:
- return True
-
- if waitClickImg_noWait_withBool(train_img.enter, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(enter_pic, 2, 1) == False:
- return False
- return True
-
- @staticmethod
- def return_line():
- if waitClickImg_noWait_withBool(monster_img.returnLine, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(monster_img.enter, 2, 1) == False:
- return False
- return True
- @staticmethod
- def add_strength():
- if waitClickImg_noWait_withBool(check_img.no_strength, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.add_strength, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(information_img.add_strength, 2, 1) == False:
- return False
- return True
- @staticmethod
- def get_line_num():
- lineStr = yys_ocrAuto(check_img.line_orc)
- if len(lineStr) == 0:
- return 0
- match = re.search(r'\d', lineStr[0]) # 查找第一个数字
- if match:
- first_digit = match.group()
- print("第一个数字:", first_digit)
- return int(first_digit)
- else:
- print("未找到数字")
- return 0
-
-
- def task_return_game():
- tryTimes = 3
- while tryTimes > 0:
- if False == waitFindImg_withBool([place_img.title], 1, 1):
- waitClickImg_noWait([place_img.ico, place_img.ico2], 1, 0)
- myTimeSleep_big()
- tryTimes -= 1
- if tryTimes == 0:
- return False
- else:
- break
- def task_save_compress_pic():
- # 截取屏幕截图
- screenshot = pyautogui.screenshot()
- compressed_data = compress_image(screenshot)
- # 保存压缩后的图像到文件
- with open('compressed_screenshot.jpg', 'wb') as f:
- f.write(compressed_data)
- def task_close_game():
- subprocess.call(f"taskkill /f /im MuMuPlayer.exe")
- subprocess.call(f"taskkill /f /im MuMuVMMHeadless.exe")
- subprocess.call(f"taskkill /f /im MuMuVMMSVC.exe")
- myTimeSleep_big()
- def task_start_game():
- isSuccess = True
- path1 = R'C:\\Program Files\\Netease\\MuMuPlayer-12.0\\shell\\MuMuPlayer.exe'
- path2 = R'C:\Program Files\Netease\MuMu Player 12\shell\MuMuPlayer.exe'
- if os.path.exists(path1):
- subprocess.Popen(path1)
- elif os.path.exists(path2):
- subprocess.Popen(path2)
- if waitClickImg_withBool(gameStart_img.ico, 100, 20) == False:
- return False
-
- waitFindImg_withBool(place_img.gameIn, 10, 20)
- basic_operate.go_town()
- waitFindImg_withBool(place_img.gameIn, 10, 20)
- basic_operate.go_town()
- if waitFindImg_withBool(place_img.gameIn, 10, 20) == False:
- return False
- myTimeSleep_big()
- return isSuccess
- class dongri_task:
- def __init__(self, name):
- self.name = name
- def run(self):
- print(f"Running task: {self.name}")
- class task_fight_yongbing(dongri_task):
- def __init__(self, add_strengh):
- super().__init__("战斗佣兵")
- self.add_strengh = add_strengh
- def run(self):
- basic_operate.go_outside()
- if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
- if self.add_strengh:
- basic_operate.add_strength()
- basic_operate.go_outside()
- else:
- print("没有足够的体力了")
- return False
-
- if waitClickImg_noWait_withBool(check_img.yongbing, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.detect, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.yongbing_fight, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
- return False
- if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
- return False
- if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
- maxTryTimes = 3
- while maxTryTimes > 0:
- maxTryTimes -= 1
- waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
- waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
- if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
- break
- return True
- class task_fight_jina_only(dongri_task):
- def __init__(self):
- super().__init__("战斗召唤的吉娜")
- def run(self):
- basic_operate.go_outside()
- #必须加体力
- if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
- basic_operate.add_strength()
- basic_operate.go_outside()
-
- if waitClickImg_noWait_withBool(check_img.talk_in, 2, 1) == False:
- return False
-
- waitClickImg_noWait_withBool(check_img.talkin_person, 2, 1)
-
- if waitClickImg_noWait_withBool(check_img.talkin_jina, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.xiaohao_jina, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
- if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
- return False
- if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
- return False
- if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
- maxTryTimes = 3
- while maxTryTimes > 0:
- maxTryTimes -= 1
- waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
- waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
- if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
- break
- return True
-
- class task_call_jina(dongri_task):
- def __init__(self):
- super().__init__("召唤吉娜")
-
- def run(self):
- basic_operate.go_outside()
- if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.share, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.to_pcacc, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.share_btn, 2, 1) == False:
- return False
- return True
-
- class task_fight_jina(dongri_task):
- def __init__(self, add_strengh):
- super().__init__("战斗吉娜")
- self.add_strengh = add_strengh
- def run(self):
- basic_operate.go_outside()
- if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
- if self.add_strengh:
- basic_operate.add_strength()
- basic_operate.go_outside()
- else:
- print("没有足够的体力了")
- return False
-
- if waitClickImg_noWait_withBool(check_img.pack, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool((check_img.other, check_img.other2), 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.jina_jiao, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.use, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(monster_img.muti_team, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
- if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
- return False
- if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
- return False
- if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
- maxTryTimes = 3
- while maxTryTimes > 0:
- maxTryTimes -= 1
- waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
- waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
- if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
- break
- return True
-
-
- class task_fightMonster(dongri_task):
- def __init__(self, add_strengh, fight_bigMonster, isSimple):
- self.add_strengh = add_strengh
- self.isSimple = isSimple
- if fight_bigMonster == True:
- super().__init__(f"战斗大怪物")
- self.monster = monster_img.bigMonster
- self.attack = monster_img.muti_team
- else:
- super().__init__(f"战斗小怪物")
- self.monster = monster_img.wolf
- self.attack = monster_img.attack
- def run(self):
- basic_operate.go_outside()
- if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
- if self.add_strengh:
- basic_operate.add_strength()
- basic_operate.go_outside()
- else:
- print("没有足够的体力了")
- return False
- if False == basic_operate.click_outside_search():
- return False
- if self.add_strengh and basic_operate.get_line_num() >= 6:
- return False
-
-
- if waitFindImg_withBool(monster_img.search, 2, 1):
- myTimeSleep_big()
- yys_dragAuto(monster_img.move_left)
- if waitClickImg_noWait_withBool(self.monster, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(self.attack, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.begin_multi, 2, 1)
- if not self.isSimple:
- if waitClickImg_noWait_withBool(monster_img.line1, 2, 1) == False:
- return False
- if waitFindImg_withBool(monster_img.no_hero, 2, 1) == True:
- return False
- if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
- maxTryTimes = 3
- while maxTryTimes > 0:
- maxTryTimes -= 1
- waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
- waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
- if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
- break
- return True
-
- class task_collect(dongri_task):
- def __init__(self, type = 0, isSimple = False, isAddStrenghth = False):
- self.isSimple = isSimple
- self.isAddStrenghth = isAddStrenghth
- if isinstance(type, (list, tuple)):
- typeArr = type
- type = typeArr[random.randint(0, len(typeArr) - 1)]
- elif type == 0:
- typeArr = [4,4,3,3,3,2,2,2,1,1]
- type = typeArr[random.randint(0, len(typeArr) - 1)]
- elif type == 5:
- typeArr = [2,1]
- type = typeArr[random.randint(0, len(typeArr) - 1)]
- if type == 1:
- self.type = monster_img.meat
- self.line = monster_img.line2
- super().__init__(f"采集肉")
- elif type == 2:
- self.type = monster_img.wood
- self.line = monster_img.line3
- super().__init__(f"采集木头")
- elif type == 3:
- self.type = monster_img.mine
- self.line = monster_img.line4
- super().__init__(f"采矿石")
- elif type == 4:
- self.type = monster_img.iron
- self.line = monster_img.line5
- super().__init__(f"采集铁矿石")
- else:
- self.type = None
- self.line = None
- super().__init__(f"采集None")
- if isSimple:
- self.line = None
-
- def run(self):
- if self.type == None:
- return True
- basic_operate.go_outside()
- if False == basic_operate.click_outside_search():
- return False
-
- if self.isAddStrenghth and basic_operate.get_line_num() >= 5:
- return False
-
-
- if waitFindImg_withBool(monster_img.search, 2, 1):
- myTimeSleep_big()
- yys_dragAuto(monster_img.move_right)
- if waitClickImg_noWait_withBool(self.type, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(monster_img.search, 2, 1) == False:
- return False
- if waitClickImg_withBool(monster_img.collect, 2, 1) == False:
- return False
-
- if self.line != None:
- waitClickImg_noWait_withBool(self.line, 2, 1)
- if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.all_select, 2, 1)
-
- maxTryTimes = 3
- while maxTryTimes > 0:
- maxTryTimes -= 1
- waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
- waitClickImg_noWait_withBool(monster_img.all_select, 1, 1)
- if waitFindImg_withBool(monster_img.all_select, 1, 1) == False:
- break
- return True
-
- class task_train(dongri_task):
- def __init__(self, train_type = None):
- super().__init__(f"检查训练{train_type}")
- self.train_type = train_type
- def run(self):
- basic_operate.go_town()
- if self.train_type == 'None':
- return True
-
- if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(train_img.train_success, 2, 1) == False:
- return False
- tryTimes = 3
- while tryTimes > 0:
- tryTimes -= 1
- waitClickImg_noWait_withBool([train_img.dun, train_img.gong, train_img.mao], 2, 1)
- if waitClickImg_noWait_withBool(train_img.train, 2, 1):
- break
-
-
- if self.train_type == 'lv1':
- myTimeSleep_big()
- yys_dragAuto(train_img.move_left)
- yys_dragAuto(train_img.move_left)
- waitClickImg_noWait_withBool(train_img.soilder_lv1, 2, 1)
- elif self.train_type == 'lv8':
- waitClickImg_noWait_withBool(train_img.soilder_lv8, 2, 1)
- elif self.train_type == 'lv9':
- waitClickImg_noWait_withBool(train_img.soilder_lv9, 2, 1)
- return basic_operate.enter_auto_supply_resource(train_img.begin_train)
- class task_checkHelp(dongri_task):
- def __init__(self, isOutSide = False):
- super().__init__(f"检查帮助")
- self.isOutSide = isOutSide
- def run(self):
- if self.isOutSide:
- basic_operate.go_outside()
- else:
- basic_operate.go_town()
- waitClickImg_noWait_withBool(place_img.help, 2, 1)
- return True
-
- class task_checkStoreRoom(dongri_task):
- def __init__(self):
- super().__init__(f"检查仓库或招募")
- def run(self):
- basic_operate.go_town()
- if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
- return False
-
- myTimeSleep_big()
- yys_dragAuto(check_img.move_down)
- yys_dragAuto(check_img.move_down)
- myTimeSleep_big()
- if waitClickImg_noWait_withBool((train_img.train_success, check_img.needgo), 2, 1) == False:
- return False
- myTimeSleep_big()
- if waitFindImg_withBool(check_img.pet_findtreature, 2, 1) == False:
- pcacc_mouse.quickclick_current()
- waitClickImg_noWait_withBool((check_img.detail,check_img.detail2), 2, 1)
- basic_operate.go_town()
- if waitClickImg_noWait_withBool((check_img.storeroom, check_img.storeroom2, check_img.invite_free), 2, 1) == False:
- return False
- myTimeSleep_big()
- pcacc_mouse.quickclick_current()
- myTimeSleep_big()
- waitClickImg_noWait_withBool(check_img.store_strength, 2, 1)
- waitClickImg_noWait_withBool((check_img.get,check_img.bigGet), 2, 1)
- else:
- if waitClickImg_noWait_withBool(check_img.pet_success, 2, 1):
- myTimeSleep_big()
- dstPos = get_yys_random_point(check_img.pet_getRegion)
- pcacc_mouse.click(dstPos[0], dstPos[1])
- myTimeSleep_big()
- elif waitClickImg_noWait_withBool((check_img.pet_advance, check_img.pet_senior, check_img.pet_junior), 2, 1):
- waitClickImg_noWait_withBool(check_img.pet_gotreature, 2, 1)
- waitClickImg_noWait_withBool(check_img.pet_begintreature, 2, 1)
- return True
-
- class task_checkConfilits(dongri_task):
- def __init__(self):
- super().__init__(f"检查集结")
- def run(self):
- basic_operate.go_outside()
- if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.paticipate, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.auto_confilit, 2, 1) == False:
- return False
- return True
- class task_checkDonata(dongri_task):
- def __init__(self):
- super().__init__(f"检查捐献")
- def run(self):
- basic_operate.go_town()
- if waitClickImg_noWait_withBool(check_img.union, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.union_technology, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.technology_better, 2, 1) == False:
- return False
- if waitClickImg_withBool([check_img.donate, check_img.donate2], 2, 1) == False:
- return False
- else:
- maxTryTimes = 3
- while waitClickImg_withBool([check_img.donate, check_img.donate2], 1, 0) and maxTryTimes > 0:
- maxTryTimes -= 1
- return True
- class task_checkAdventure(dongri_task):
- def __init__(self):
- super().__init__(f"检查冒险")
- def run(self):
- basic_operate.go_town()
- if waitClickImg_noWait_withBool(check_img.adventure, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.get, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.bigGet, 2, 1) == False:
- return False
- return True
- class task_waitTime(dongri_task):
- def __init__(self):
- super().__init__(f"等待时间")
- def run(self):
- myTimeSleep(300)
- class check_buildOrResearch(dongri_task):
- def __init__(self):
- super().__init__(f"检查建筑或研究")
- def run(self):
- basic_operate.go_town()
- if waitClickImg_noWait_withBool(train_img.quick_panel, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.needgo, 2, 1) == False:
- return False
-
- dstType = 'none'
- while True:
- 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):
- dstType = 'build'
- break
- handRet, handPos = waitFindImg(check_img.hand, 2, 1)
- if not handRet:
- return False
-
- detailRet, detailPos = waitFindImg((check_img.detail,check_img.detail2), 2, 1)
- dstPos = [0, 0]
- if not detailRet:
- # 如果找不到详细信息,兵营之类的,需点中间
- dstPos = [handPos[0] - 70, handPos[1] + 120]
- else:
- dstPos = [detailPos[0] + 70, detailPos[1] - 100]
- tryTimes = 5
-
- while tryTimes > 0:
- tryTimes -= 1
- myTimeSleep_big()
- pcacc_mouse.click(dst_x=dstPos[0], dst_y=dstPos[1])
-
- if waitClickImg_noWait_withBool(check_img.research, 2, 1):
- dstType = 'research'
- break
- elif waitClickImg_noWait_withBool(check_img.build_upgrade, 2, 1):
- dstType = 'build'
- break
- break
- if dstType == 'none':
- print('没有找到建筑或研究')
- return False
- elif dstType == 'build':
- buildtimes = 4
- 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]):
- buildtimes -= 1
- if buildtimes == 0:
- break
- continue
- elif dstType == 'research':
- if waitClickImg_withBool([check_img.research_type1, check_img.research_type2], 2, 1) == False:
- return False
- if basic_operate.enter_auto_supply_resource(check_img.research_done) == False:
- return False
-
- waitClickImg_withBool([check_img.help, check_img.help2, check_img.help3], 2, 2)
- return True
-
- class task_information(dongri_task):
- def __init__(self, isAddStrengh = False):
- super().__init__(f"检查情报")
- self.isAddStrengh = isAddStrengh
- def run(self):
- basic_operate.go_outside()
- if False == waitFindImg_withBool(monster_img.enough_strengh, 2, 1):
- if self.isAddStrengh:
- basic_operate.add_strength()
- basic_operate.go_outside()
- else:
- print("没有足够的体力了")
- return False
- if waitClickImg_noWait_withBool(information_img.information, 1, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool([information_img.hero0, information_img.hero1, information_img.hero2], 0.5, 0.5):
- if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
- return False
- if waitClickImg_noWait_withBool(information_img.explore, 1, 1) == False:
- return False
- if waitClickImg_noWait_withBool(information_img.hero_fight, 1, 1) == False:
- return False
-
- myTimeSleep_big()
- return True
- elif waitClickImg_noWait_withBool([information_img.camp1, information_img.camp2], 0.5, 0.5):
- if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
- return False
- if waitClickImg_noWait_withBool(information_img.survive, 1, 1) == False:
- return False
- return True
- elif waitClickImg_noWait_withBool([information_img.wolf0, information_img.wolf1, information_img.wolf2], 0.5, 0.5):
- if waitClickImg_noWait_withBool(information_img.gotosee, 1, 1) == False:
- return False
- if waitClickImg_noWait_withBool(information_img.fight, 1, 1) == False:
- return False
- if waitClickImg_noWait_withBool(monster_img.line1, 1, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
- maxTryTimes = 3
- while maxTryTimes > 0:
- maxTryTimes -= 1
- waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
- if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
- break
-
- return True
- else:
- return False
- class task_returnAllLine(dongri_task):
- def __init__(self):
- super().__init__(f"返回所有路线")
- def run(self):
- basic_operate.go_outside()
- basic_operate.return_line()
- basic_operate.return_line()
- basic_operate.return_line()
- basic_operate.return_line()
- basic_operate.return_line()
- basic_operate.return_line()
- return True
- class task_paticipateInTeam(dongri_task):
- def __init__(self):
- super().__init__(f"参与队伍")
- def run(self):
- basic_operate.go_outside()
- if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(monster_img.participate, 1, 1) == False:
- return False
-
- while True:
- if waitClickImg_noWait_withBool(monster_img.line1, 0.1, 1) == False:
- break
- if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
- break
- if waitClickImg_noWait_withBool(monster_img.line4, 0.1, 1) == False:
- break
- if waitFindImg_withBool(monster_img.no_hero, 0.1, 1) == False:
- break
- break
-
- if waitClickImg_noWait_withBool(monster_img.all_select, 2, 1) == False:
- return False
- waitClickImg_noWait_withBool(monster_img.all_select, 0.1, 1)
- maxTryTimes = 3
- while maxTryTimes > 0:
- maxTryTimes -= 1
- waitClickImg_withBool([monster_img.fight, monster_img.fight2], 1, 1)
- if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 1):
- break
- return True
- class task_cure(dongri_task):
- def __init__(self, continueCure = False, cureNum = None):
- super().__init__(f"治疗")
- self.continueCure = continueCure
- self.cureNum = cureNum
- def run(self):
- basic_operate.go_outside()
- if waitClickImg_noWait_withBool(check_img.soilder_cure, 2, 1) == False:
- return False
-
- if self.continueCure == False:
- if waitClickImg_noWait_withBool(check_img.cure, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool(check_img.help4, 2, 1) == False:
- return False
- else:
- maxTryTimes = 50
- while waitClickImg_noWait_withBool((check_img.cure, check_img.help4), 30, 1) and maxTryTimes >= 0:
- maxTryTimes -= 1
- continue
-
- return True
- class task_useAnnimalSkill(dongri_task):
- def __init__(self):
- super().__init__(f"使用动物技能")
- def run(self):
- basic_operate.go_outside()
- if waitClickImg_noWait_withBool(check_img.annimal_skill, 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool((check_img.wolf_skill, check_img.elephant_skill), 2, 1) == False:
- return False
-
- if waitClickImg_noWait_withBool((check_img.use, check_img.use2), 2, 1) == False:
- return False
- class task_activity_lianmeng(dongri_task):
- def __init__(self):
- super().__init__(f"联盟总动员")
- def run(self):
- basic_operate.go_town()
- if waitClickImg_noWait_withBool(special_activity_img.normal, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool((special_activity_img.lianmeng,special_activity_img.lianmeng2), 2, 1) == False:
- return False
-
- waitClickImg_noWait_withBool(special_activity_img.task_done, 2, 1)
-
- if waitFindImg_withBool(special_activity_img.doing_task, 2, 1) == False:
- if waitClickImg_noWait_withBool((special_activity_img.shili_120, special_activity_img.shili_860), 2, 1) == True:
- if waitClickImg_noWait_withBool(special_activity_img.accept_task, 2, 1) == False:
- return False
-
- if waitFindImg_withBool((special_activity_img.shili_120, special_activity_img.shili_860), 2, 1) == False:
- maxTryTimes = 2
- while waitClickImg_noWait_withBool((special_activity_img.owning, special_activity_img.owning_120), 2, 1) == True:
- waitClickImg_noWait_withBool(special_activity_img.refresh_task, 2, 1)
- waitClickImg_noWait_withBool(special_activity_img.refresh, 2, 1)
- maxTryTimes -= 1
- if maxTryTimes <= 0:
- break
- return True
-
- class task_checkMaster(dongri_task):
- def __init__(self):
- super().__init__(f"检查统帅")
- def run(self):
- basic_operate.go_town()
- if waitClickImg_noWait_withBool(check_img.master, 2, 1) == False:
- return False
- if waitClickImg_noWait_withBool(check_img.master_get, 2, 1) == False:
- return False
- myTimeSleep_big()
- pcacc_mouse.quickclick_current()
- if waitClickImg_noWait_withBool(check_img.little_treasure, 2, 1) == False:
- return False
- return True
- class task_checkActivities(dongri_task):
- def __init__(self):
- super().__init__(f"检查各种活动时间")
- def find_all_matching_events(parts, input_word):
- results = []
- # 查找所有包含输入关键词的项
- matches = [i for i, part in enumerate(parts) if input_word in part]
- for match_index in matches:
- # 从匹配项开始向后查找第一个时间或状态
- for i in range(match_index + 1, len(parts)):
- current_part = parts[i]
- # 检查是否是时间(如 19:30)或状态(如 已结束)
- if re.match(r'^\d{1,2}:\d{2}$', current_part) or current_part in ["已结束"]:
- dst = {"item":parts[match_index], "time":current_part}
- results.append(dst)
- break # 找到第一个匹配就停止
-
- return results
- def run(self):
- global todo_msg, todo_list
- basic_operate.go_outside()
- if waitClickImg_noWait_withBool(check_img.activity_open, 2, 1) == False:
- return False
- if waitFindImg_withBool(check_img.todoList, 2, 1) == False:
- return False
-
- activityStr = yys_ocrAuto(check_img.todo_region)
- if activityStr:
- todo_msg = activityStr
- print(todo_msg)
- result = []
- '''
- ['北京时间', '2025-04-01', '据点争夺', '07:00', '3级科技工程站']
- judianArr = self.find_all_matching_events(activityStr, "据点")
- result.extend(judianArr)
-
- baoleiArr = self.find_all_matching_events(activityStr, "堡垒")
- result.extend(baoleiArr)
-
- juxiongArr = self.find_all_matching_events(activityStr, "巨熊")
- result.extend(juxiongArr)
- yaosaiArr = self.find_all_matching_events(activityStr, "要塞")
- result.extend(yaosaiArr)
- todo_list = result
- '''
- return activityStr
- if __name__ == '__main__':
- task_call_jina().run()
- #task_checkConfilits().run()
- #task_checkActivities().run()
- #task_checkMaster().run()
- #basic_operate.get_line_num()
- #yys_ocrAuto(check_img.line_orc)
- #basic_operate.go_town()
- #basic_operate.add_strength()
- #task_fightMonster(False, False,False).run()
- #task_checkHelp().run()
- #task_checkStoreRoom().run()
- #task_activity_lianmeng().run()
- #task_fight_yongbing(True).run()
- #task_collect([4,3,2,1]).run()
- #task_train("lv9").run()
- #task_information().run()
- #check_buildOrResearch().run()
- #task_checkDonata().run()
- #task_collect(1).run()
- #task_collect(2).run()
- #task_collect(3).run()
- #task_collect(4).run()
- #task_returnAllLine().run()
- #task_paticipateInTeam().run()
- #task_fight_jina(True).run()
|