Skip to content

Commit

Permalink
1.0.1.0304
Browse files Browse the repository at this point in the history
  • Loading branch information
AcademicDog committed Mar 4, 2020
1 parent 2de3dc6 commit 9a026d7
Show file tree
Hide file tree
Showing 19 changed files with 579 additions and 98 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## v1.0.1.0304
#### New features:
* 探索双开
#### Fixes (bugs & defects):
* 修复了探索副本中不停反复点击准备按钮的问题。
* 修复了部分玩家BitBlt失败的问题。
* 优化了结算

## v1.0.1.0301
#### New features:
* 增加延迟设定选项。
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

感谢壁咚咚咚咚咚、Tree.提供的技术指导,感谢Abc为本程序提供了应用图标。

感谢以下人员为测试工作做出的努力:鼠白小验实,忒修斯之旅,Garry。
感谢以下人员为测试工作做出的努力:鼠白小验实,忒修斯之旅,Garry,DD斩首, 暖

# 注意事项

Expand Down
7 changes: 6 additions & 1 deletion conf_example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
client = 0
#run_section 运行副本:0-御魂;1-御灵;2-探索
run_section = 0
#run_mode 运行模式:对于御魂0-单刷;1-司机;2-乘客;3-双开
#run_mode 御魂运行模式:0-单刷;1-司机;2-乘客;3-双开
run_mode = 0
#max_times 最大游戏次数:0-无数次;其他-其他次
max_times = 0
Expand All @@ -29,6 +29,11 @@ max_op_time = 20

[explore]
#######探索参数######
#explore_mode 探索模式:0-单刷;1-队长;2-队员;3-双开
explore_mode = 0
#更换狗粮设置:1-左; 2-中; 3-右; 4-左后; 5-右后,下同
gouliang = [2, 3]
gouliang_b = []
#fight_boss_enable 结束后是否打BOSS:True-是;False-否
fight_boss_enable = False
#slide_shikigami 换狗粮是否拖放式神进度条:True-是;False-否
Expand Down
85 changes: 66 additions & 19 deletions explore/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,34 @@


class ExploreFight(Fighter):
def __init__(self):
# 初始化
Fighter.__init__(self)
def __init__(self, hwnd=0, mode=0):
'''
初始化
:param hwnd=0: 指定窗口句柄:0-否;其他-窗口句柄
:param mode=0: 狗粮模式:0-正常模式,1-组队后排狗粮
'''
Fighter.__init__(self, hwnd=hwnd)

# 读取配置文件
conf = configparser.ConfigParser()
conf.read('conf.ini')

# 读取狗粮配置
if mode == 0:
raw_gouliang = conf.get('explore', 'gouliang')
else:
raw_gouliang = conf.get('explore', 'gouliang_b')
if len(raw_gouliang) == 2:
self.gouliang = None
elif len(raw_gouliang) == 3:
self.gouliang = [int(raw_gouliang[1])]
elif len(raw_gouliang) == 6:
self.gouliang = [int(raw_gouliang[1]), int(raw_gouliang[4])]
elif len(raw_gouliang) == 9:
self.gouliang = [int(raw_gouliang[1]), int(
raw_gouliang[4]), int(raw_gouliang[7])]

# 读取其他配置
self.fight_boss_enable = conf.getboolean(
'explore', 'fight_boss_enable')
self.slide_shikigami = conf.getboolean('explore', 'slide_shikigami')
Expand All @@ -36,18 +57,34 @@ def next_scene(self):
def check_exp_full(self):
'''
检查狗粮经验,并自动换狗粮
狗粮序列,1-左; 2-中; 3-右; 4-左后; 5-右后
'''
# 狗粮经验判断, gouliang1是中间狗粮,gouliang2是右边狗粮
gouliang1 = self.yys.find_game_img(
'img\\MAN1.png', 1, *TansuoPos.gouliang_middle, 1)
gouliang2 = self.yys.find_game_img(
'img\\MAN2.png', 1, *TansuoPos.gouliang_right, 1)
if self.gouliang == None:
return

# print(gouliang1)
# print(gouliang2)
# 狗粮经验判断
gouliang = []
if 1 in self.gouliang:
gouliang.append(self.yys.find_game_img(
'img\\MAN2.png', 1, *TansuoPos.gouliang_left, 1, 0.8))
if 2 in self.gouliang:
gouliang.append(self.yys.find_game_img(
'img\\MAN2.png', 1, *TansuoPos.gouliang_middle, 1, 0.8))
if 3 in self.gouliang:
gouliang.append(self.yys.find_game_img(
'img\\MAN2.png', 1, *TansuoPos.gouliang_right, 1, 0.8))
if 4 in self.gouliang:
gouliang.append(self.yys.find_game_img(
'img\\MAN2.png', 1, *TansuoPos.gouliang_leftback, 1, 0.8))
if 5 in self.gouliang:
gouliang.append(self.yys.find_game_img(
'img\\MAN2.png', 1, *TansuoPos.gouliang_rightback, 1, 0.8))

# 如果都没满则退出
if not gouliang1 and not gouliang2:
res = False
for item in gouliang:
res = res or bool(item)
if not res:
return

# 开始换狗粮
Expand Down Expand Up @@ -84,13 +121,22 @@ def check_exp_full(self):

self.yys.mouse_drag_bg(
TansuoPos.n_slide[0], (pos_end_x, pos_end_y))
time.sleep(1)

# 更换狗粮
if gouliang1:
self.yys.mouse_drag_bg((309, 520), (554, 315))
if gouliang2:
time.sleep(1)
self.yys.mouse_drag_bg((191, 520), (187, 315))
for i in range(0, len(self.gouliang)):
if gouliang[i]:
if self.gouliang[i] == 1:
self.yys.mouse_drag_bg((422, 520), (955, 315))
elif self.gouliang[i] == 2:
self.yys.mouse_drag_bg((309, 520), (554, 315))
elif self.gouliang[i] == 3:
self.yys.mouse_drag_bg((191, 520), (167, 315))
elif self.gouliang[i] == 4:
self.yys.mouse_drag_bg((309, 520), (829, 315))
elif self.gouliang[i] == 5:
self.yys.mouse_drag_bg((191, 520), (301, 315))
ut.mysleep(1000)

def find_exp_moster(self):
'''
Expand Down Expand Up @@ -160,7 +206,7 @@ def fight_moster(self, mood1, mood2):
return -1

# 攻击怪
self.yys.mouse_click_bg(fight_pos)
self.click_until('怪', 'img/YING-BING.png', fight_pos, step_time=0.3, appear=False)
self.log.writeinfo('已进入战斗')

# 等待式神准备
Expand All @@ -171,8 +217,8 @@ def fight_moster(self, mood1, mood2):
self.check_exp_full()

# 点击准备,直到进入战斗
self.click_until('准备按钮', 'img\\ZI-DONG.png', *
TansuoPos.ready_btn, mood1.get1mood()/1000)
self.click_until('准备按钮', 'img/ZHUN-BEI.png', *
TansuoPos.ready_btn, mood1.get1mood()/1000, False)

# 检查是否打完
state = self.check_end()
Expand Down Expand Up @@ -204,6 +250,7 @@ def start(self):
if result == 1:
continue
elif result == 2:
time.sleep(1)
break
else:
self.log.writeinfo('移动至下一个场景')
Expand Down
61 changes: 61 additions & 0 deletions explore/explore_dual.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from gameLib.game_ctl import GameControl
from explore.explore_leader import ExploreLeader
from explore.explore_passenger import ExplorePassenger

import logging
import threading
import win32gui

hwndlist = []


def get_all_hwnd(hwnd, mouse):
'''
获取所有阴阳师窗口
'''
if win32gui.IsWindow(hwnd) and win32gui.IsWindowEnabled(hwnd) and win32gui.IsWindowVisible(hwnd):
if win32gui.GetWindowText(hwnd) == u'阴阳师-网易游戏':
hwndlist.append(hwnd)


def get_game_hwnd():
win32gui.EnumWindows(get_all_hwnd, 0)


class ExploreDual():
def __init__(self):
# 初始化窗口信息
get_game_hwnd()
self.hwndlist = hwndlist

# 检测窗口信息是否正确
num = len(self.hwndlist)
if num == 2:
logging.info('检测到两个窗口,窗口信息正常')
else:
logging.warning('检测到'+str(num)+'个窗口,窗口信息异常!')

# 初始化司机和打手
for hwnd in hwndlist:
yys = GameControl(hwnd)
if yys.find_game_img('img/DUI.png', 1, (68, 242), (135, 306), thread=0.8):
self.driver = ExploreLeader(hwnd=hwnd)
hwndlist.remove(hwnd)
logging.info('发现队长')
break
self.passenger = ExplorePassenger(hwnd=hwndlist[0])
logging.info('发现乘客')

def start(self):
task1 = threading.Thread(target=self.driver.start)
task2 = threading.Thread(target=self.passenger.start)
task1.start()
task2.start()

task1.join()
task2.join()

def deactivate(self):
self.hwndlist = []
self.driver.deactivate()
self.passenger.deactivate()
116 changes: 116 additions & 0 deletions explore/explore_leader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
from explore.explore import ExploreFight
from tools.game_pos import TansuoPos
import tools.utilities as ut

import logging
import random
import time


class ExploreLeader(ExploreFight):
'''
组队探索队长
'''

def __init__(self, hwnd=0):
'''
初始化
'''
ExploreFight.__init__(self, hwnd=hwnd, mode=1)
self.name = 'Leader: '

def prev_scene(self):
'''
滑动到前一页面
'''
x0 = random.randint(510, 1126)
x1 = x0 - 500
y0 = random.randint(110, 210)
y1 = random.randint(110, 210)
self.yys.mouse_drag_bg((x1, y1), (x0, y0))

def start(self):
'''
开始战斗
'''
mood1 = ut.Mood(3)
mood2 = ut.Mood(3)
mood3 = ut.Mood()
scene = self.get_scene()
if scene == 4:
logging.info('Leader: 已进入探索,就绪')
else:
logging.warning('Leader: 请检查是否进入探索内,退出')
return

while self.run:
# 检测当前场景
maxVal_list, maxLoc_list = self.yys.find_multi_img(
'img/DUI.png', 'img/YING-BING.png')
if maxVal_list[0] < 0.8 and maxVal_list[1] > 0.8:
# 队长退出,结束
logging.warning('Leader: 队员已退出,脚本结束')
self.yys.quit_game()

# 开始打怪
i = 0
ok = False
while self.run:
if i >= 4:
break
result = self.fight_moster(mood1, mood2)
if result == 1:
ok = True
continue
elif result == 2:
break
else:
self.log.writeinfo('Leader: 移动至下一个场景')
self.next_scene()
i += 1

if not ok:
# 没有经验怪,随便打一个
fight_pos = self.yys.find_game_img('img/FIGHT.png')
while not fight_pos:
self.prev_scene()
fight_pos = self.yys.find_game_img('img/FIGHT.png')
# 攻击怪
self.yys.mouse_click_bg(fight_pos)
self.log.writeinfo('Leader: 已进入战斗')

# 等待式神准备
self.yys.wait_game_img_knn('img/ZHUN-BEI.png', thread=30)
logging.info('Leader: 式神准备完成')

# 检查狗粮经验
self.check_exp_full()

# 点击准备,直到进入战斗
self.click_until('准备按钮', 'img/ZHUN-BEI.png', *
TansuoPos.ready_btn, mood1.get1mood()/1000, False)

# 检查是否打完
state = self.check_end()
mood1.moodsleep()

# 在战斗结算页面
self.get_reward(mood2, state)

# 退出探索
self.log.writeinfo('Leader: 结束本轮探索')
# 点击退出探索
self.click_until('退出按钮', 'img/QUE-REN.png',
*TansuoPos.quit_btn, 2)
# 点击确认
self.click_until('确认按钮', 'img/QUE-REN.png',
*TansuoPos.confirm_btn, 2, False)

# 下一轮自动邀请
self.yys.wait_game_img('img/QUE-DING.png', self.max_win_time)
time.sleep(0.5)
self.click_until('继续邀请', 'img/QUE-DING.png', *
TansuoPos.yaoqing_comfirm, mood3.get1mood()/1000, False)

# 检查游戏次数
self.check_times()
Loading

0 comments on commit 9a026d7

Please sign in to comment.