Skip to content

Commit

Permalink
1.0.1.0226
Browse files Browse the repository at this point in the history
  • Loading branch information
AcademicDog committed Feb 26, 2020
1 parent 76932cf commit f379ddc
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 54 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# CHANGELOG

## v1.0.1.0226
#### New features:
* 取消了满级狗粮识别的延迟设定,现在改为更智能的自动处理方式。
* 针对近期鬼使黑的问题,大幅优化了结算方式。

## v1.0.1.0224
#### New features:
* 系统缩放自适应。
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

同时感谢sup817ch的图像识别思路,本项目game_ctl模块基于其[工作基础](https://github.com/sup817ch/AutoOnmyoji)

感谢Abc为本程序提供了应用图标。

# 注意事项

环境:python 3.7, 32 bit;yys PC端 默认分辨率 (1136x640);win 10系统,屏幕(1920x1080),显示设置100%。
Expand Down
2 changes: 0 additions & 2 deletions conf_example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ fight_boss_enable = False
slide_shikigami = True
#slide_shikigami_progress 进度条位置(百分比)
slide_shikigami_progress = 10
#zhunbei_delay 满级狗粮识别延迟(秒)
zhunbei_delay = 3
#change_shikigami 更换狗粮卡片:0-素材;1-N卡;2-R卡
change_shikigami = 1

Expand Down
16 changes: 4 additions & 12 deletions explore/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def __init__(self):
self.slide_shikigami = conf.getboolean('explore', 'slide_shikigami')
self.slide_shikigami_progress = conf.getint(
'explore', 'slide_shikigami_progress')
self.zhunbei_delay = conf.getfloat('explore', 'zhunbei_delay')
self.change_shikigami = conf.getint('explore', 'change_shikigami')

def next_scene(self):
Expand Down Expand Up @@ -161,14 +160,11 @@ def fight_moster(self, mood1, mood2):
return -1

# 攻击怪
self.yys.mouse_click_bg(fight_pos)
if not self.yys.wait_game_img('img\\ZHUN-BEI.png', self.zhunbei_delay, False):
break
self.yys.mouse_click_bg(fight_pos)
self.log.writeinfo('已进入战斗')
time.sleep(1)

# 等待式神准备
#self.yys.wait_game_color(((1024,524),(1044, 544)), (138,198,233), 30)
self.yys.wait_game_img_knn('img\\ZHUN-BEI.png', thread=30)
logging.info('式神准备完成')

# 检查狗粮经验
Expand All @@ -179,15 +175,11 @@ def fight_moster(self, mood1, mood2):
TansuoPos.ready_btn, mood1.get1mood()/1000)

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

# 在战斗结算页面
self.yys.mouse_click_bg(ut.firstposition())
self.click_until('结算', 'img/JIN-BI.png',
*CommonPos.second_position, mood2.get1mood()/1000)
self.click_until('结算', 'img/JIN-BI.png',
*CommonPos.second_position, mood2.get1mood()/1000, False)
self.get_reward(mood2, state)

# 返回结果
if boss:
Expand Down
42 changes: 37 additions & 5 deletions gameLib/fighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from gameLib.game_scene import GameScene
from tools.logsystem import WriteLog
from tools.game_pos import TansuoPos, YuhunPos
import tools.utilities as ut

import configparser
import logging
Expand Down Expand Up @@ -67,10 +68,17 @@ def check_battle(self):
self.log.writeinfo(self.name + '已进入战斗')

def check_end(self):
# 检测是否打完
'''
检测是否打完
:return: 胜利页面返回0;奖励页面返回1
'''
self.log.writeinfo(self.name + '检测是战斗是否结束')
self.yys.wait_game_img('img\\JIE-SU.png', self.max_win_time)
self.log.writeinfo(self.name + "战斗结束")
if self.yys.wait_game_img_knn('img/SHENG-LI.png', self.max_win_time, False, 8):
logging.info('战斗成功')
return 0
elif self.yys.wait_game_img_knn('img/TIAO-DAN.png', 2, thread=20):
logging.info('本轮战斗结束')
return 1

def check_times(self):
'''
Expand All @@ -90,6 +98,30 @@ def check_times(self):
self.run = False
os._exit(0)

def get_reward(self, mood, state):
'''
结算处理
:param mood: 状态函数
:param state: 上一步的状态。0-战斗成功页面; 1-领取奖励页面
'''
if state == 0:
self.click_until_knn('奖励', 'img/TIAO-DAN.png', ut.firstposition(), None, mood.get1mood()/1000, thread=20)
start_time = time.time()
while time.time()-start_time <= self.max_op_time and self.run:
result = self.yys.find_game_img_knn('img/TIAO-DAN.png', thread=2)
if not result:
logging.info(self.name + '结算成功')
return
else:
self.yys.mouse_click_bg(ut.secondposition())
self.log.writeinfo(self.name + '点击结算')
mood.moodsleep()
self.log.writewarning(self.name + '点击结算失败!')
# 提醒玩家点击失败,并在5s后退出
self.yys.activate_window()
time.sleep(5)
self.yys.quit_game()

def mitama_team_click(self):
'''
御魂标记己方式神
Expand Down Expand Up @@ -151,7 +183,7 @@ def click_until(self, tag, img_path, pos, pos_end=None, step_time=0.5, appear=Tr
# 点击指定位置并等待下一轮
self.yys.mouse_click_bg(pos, pos_end)
self.log.writeinfo(self.name + '点击 ' + tag)
time.sleep(step_time)
ut.mysleep(step_time*1000)
self.log.writewarning(self.name + '点击 ' + tag + ' 失败!')

# 提醒玩家点击失败,并在5s后退出
Expand Down Expand Up @@ -184,7 +216,7 @@ def click_until_knn(self, tag, img_path, pos, pos_end=None, step_time=0.5, appea
# 点击指定位置并等待下一轮
self.yys.mouse_click_bg(pos, pos_end)
self.log.writeinfo(self.name + '点击 ' + tag)
time.sleep(step_time)
ut.mysleep(step_time*1000)
self.log.writewarning(self.name + '点击 ' + tag + ' 失败!')

# 提醒玩家点击失败,并在5s后退出
Expand Down
7 changes: 2 additions & 5 deletions goryou/single_fight.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,11 @@ def start(self):
self.click_monster()

# 检测是否打完
logging.info(self.name + '检测是战斗是否结束')
self.yys.wait_game_img('img\\JIN-BI.png', self.max_win_time)
logging.info(self.name + "战斗结束")
state = self.check_end()
mood2.moodsleep()

# 在战斗结算页面
self.click_until_knn('结算', 'img\\TIAO-ZHAN.png',
*CommonPos.second_position, mood3.get1mood()/1000, thread=20)
self.get_reward(mood3, state)
logging.info("回到选择界面")

# 检查游戏次数
Expand Down
11 changes: 0 additions & 11 deletions gui/tkui.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def __init__(self, master=None):
self.fight_boss_enable = tk.BooleanVar()
self.slide_shikigami = tk.BooleanVar()
self.slide_shikigami_progress = tk.IntVar()
self.zhunbei_delay = tk.IntVar()
self.change_shikigami = 1

self.debug_enable = tk.BooleanVar()
Expand All @@ -38,7 +37,6 @@ def __init__(self, master=None):
self.fight_boss_enable.set(False)
self.slide_shikigami.set(True)
self.slide_shikigami_progress.set(10)
self.zhunbei_delay.set(3)
self.debug_enable.set(False)

# 创建菜单栏
Expand Down Expand Up @@ -186,13 +184,6 @@ def create_frame2(self):
s.config(command=text.yview)
text.config(yscrollcommand=s.set, state=tk.DISABLED)

# 延迟设置
delay = tk.LabelFrame(self.frame2, text='延迟设置')
delay.pack(fill=tk.X)
tk.Label(delay, text='满级狗粮识别延迟:').grid(row=0, column=0)
tk.Entry(delay, textvariable=self.zhunbei_delay,
width=5).grid(row=0, column=1)

# 换狗粮设置
tk.Checkbutton(self.frame2, text='换狗粮拖放式神进度条,进度:',
variable=self.slide_shikigami).pack(anchor=tk.W)
Expand Down Expand Up @@ -299,8 +290,6 @@ def show_params(self):
str(self.slide_shikigami.get()))
self.params.insert(tk.END, '\nslide_shikigami_progress: ' +
str(self.slide_shikigami_progress.get()))
self.params.insert(tk.END, '\nzhunbei_delay: ' +
str(self.zhunbei_delay.get()))
self.params.insert(tk.END, '\nchange_shikigami: ' +
str(self.cmb.current()))
self.params.insert(tk.END, '\ndebug_enable: ' +
Expand Down
Binary file removed img/JIN-BI.png
Binary file not shown.
Binary file added img/SHENG-LI.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/TIAO-DAN.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions mitama/fighter_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,11 @@ def start(self):
self.click_monster()

# 检测是否打完
self.check_end()
state = self.check_end()
mood2.moodsleep()

# 在战斗结算页面
self.yys.mouse_click_bg(ut.firstposition())
self.click_until('结算', 'img/JIN-BI.png',
*CommonPos.second_position, mood3.get1mood()/1000)
self.click_until('结算', 'img/JIN-BI.png',
*CommonPos.second_position, mood3.get1mood()/1000, False)
self.get_reward(mood3, state)

# 等待下一轮
logging.info('Driver: 等待下一轮')
Expand Down
8 changes: 2 additions & 6 deletions mitama/fighter_passenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@ def start(self):
self.click_monster()

# 检测是否打完
self.check_end()
state = self.check_end()
mood2.moodsleep()

# 在战斗结算页面
self.yys.mouse_click_bg(ut.firstposition())
self.click_until('结算', 'img/JIN-BI.png',
*CommonPos.second_position, mood3.get1mood()/1000)
self.click_until('结算', 'img/JIN-BI.png',
*CommonPos.second_position, mood3.get1mood()/1000, False)
self.get_reward(mood3, state)

# 等待下一轮
logging.info('Passenger: 等待下一轮')
Expand Down
6 changes: 2 additions & 4 deletions mitama/single_fight.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ def start(self):
self.click_monster()

# 检测是否打完
self.check_end()
state = self.check_end()
mood2.moodsleep()

# 在战斗结算页面
self.yys.mouse_click_bg(ut.firstposition())
self.click_until_knn('结算', 'img\\TIAO-ZHAN.png',
*CommonPos.second_position, mood3.get1mood()/1000, thread=20)
self.get_reward(mood3, state)
self.log.writeinfo("回到选择界面")

# 检查游戏次数
Expand Down
5 changes: 4 additions & 1 deletion tools/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,8 @@ def mysleep(slpa, slpb=0):
randomly sleep for a short time between `slpa` and `slpa + slpb` \n
because of the legacy reason, slpa and slpb are in millisecond
'''
slp = random.randint(slpa, slpa+slpb)
if slpb == 0:
slp = random.randint(int(0.5*slpa), int(1.5*slpa))
else:
slp = random.randint(slpa, slpa+slpb)
time.sleep(slp/1000)
2 changes: 0 additions & 2 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ def set_conf(self):
str(self.slide_shikigami.get()))
self.conf.set('explore', 'slide_shikigami_progress',
str(self.slide_shikigami_progress.get()))
self.conf.set('explore', 'zhunbei_delay',
str(self.zhunbei_delay.get()))
self.conf.set('explore', 'change_shikigami',
str(self.cmb.current()))

Expand Down

0 comments on commit f379ddc

Please sign in to comment.