-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2de3dc6
commit 9a026d7
Showing
19 changed files
with
579 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Oops, something went wrong.