Skip to content

Commit

Permalink
1.0.1.0224
Browse files Browse the repository at this point in the history
  • Loading branch information
AcademicDog committed Feb 25, 2020
1 parent f06fd58 commit 76932cf
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## v1.0.1.0224
#### New features:
* 系统缩放自适应。
* 增加了游戏次数的选项。
* 增加了游戏结束后的选项。
* 为本程序增加了图标。

## v1.0.1.0221
#### New features:
* 采用了新的算法,大幅度提高了图片识别的准确性,目前在部分场景有应用。
Expand Down
4 changes: 4 additions & 0 deletions conf_example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
run_section = 0
#run_mode 运行模式:对于御魂0-单刷;1-司机;2-乘客;3-双开
run_mode = 0
#max_times 最大游戏次数:0-无数次;其他-其他次
max_times = 0
#end_operation 结束后操作:0-结束后关闭脚本;1-结束后关闭脚本和游戏
end_operation = 0

[mitama]
######御魂参数#####
Expand Down
3 changes: 3 additions & 0 deletions explore/explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,6 @@ def start(self):
self.switch_to_scene(3)
self.log.writeinfo('结束本轮探索')
time.sleep(0.5)

# 检查游戏次数
self.check_times()
22 changes: 22 additions & 0 deletions gameLib/fighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import configparser
import logging
import os
import random
import threading
import time
Expand Down Expand Up @@ -32,6 +33,9 @@ def __init__(self, name='', emyc=0, hwnd=0):
self.max_op_time = conf.getint('watchdog', 'max_op_time')
self.max_win_time = conf.getint('watchdog', 'max_win_time')
self.mitama_team_mark = conf.getint('mitama', 'mitama_team_mark')
self.max_times = conf.getint('DEFAULT', 'max_times')
self.end_operation = conf.getint('DEFAULT', 'end_operation')
self.run_times = 0

# 启动日志
self.log = WriteLog()
Expand Down Expand Up @@ -68,6 +72,24 @@ def check_end(self):
self.yys.wait_game_img('img\\JIE-SU.png', self.max_win_time)
self.log.writeinfo(self.name + "战斗结束")

def check_times(self):
'''
监测游戏次数是否达到最大次数
'''
self.run_times = self.run_times + 1
logging.info('游戏已运行'+str(self.run_times)+'次')
if(self.run_times == self.max_times):
if(self.end_operation == 0):
logging.warning('关闭脚本(次数已满)...')
self.run = False
os._exit(0)
elif(self.end_operation == 1):
logging.warning('关闭游戏(次数已满)...')
self.yys.quit_game()
logging.warning('关闭脚本(次数已满)...')
self.run = False
os._exit(0)

def mitama_team_click(self):
'''
御魂标记己方式神
Expand Down
4 changes: 2 additions & 2 deletions gameLib/game_ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ def __init__(self, hwnd, quit_game_enable=1):
self.hwnd = hwnd
self.quit_game_enable = quit_game_enable
self.debug_enable = False
#user32 = ctypes.windll.user32
# user32.SetProcessDPIAware()
l1, t1, r1, b1 = win32gui.GetWindowRect(self.hwnd)
#print(l1,t1, r1,b1)
l2, t2, r2, b2 = win32gui.GetClientRect(self.hwnd)
#print(l2,t2,r2,b2)
self._client_h = b2 - t2
self._client_w = r2 - l2
self._border_l = ((r1 - l1) - (r2 - l2)) // 2
Expand Down
3 changes: 3 additions & 0 deletions goryou/single_fight.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ def start(self):
self.click_until_knn('结算', 'img\\TIAO-ZHAN.png',
*CommonPos.second_position, mood3.get1mood()/1000, thread=20)
logging.info("回到选择界面")

# 检查游戏次数
self.check_times()
31 changes: 28 additions & 3 deletions gui/tkui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.master.iconbitmap('img/icon/OnmyojiBot.ico')
self.master.wm_title('OnmyojiBot')
self.pack()

# 初始化参数
self.run_section = 0
self.run_mode = tk.IntVar()
self.run_submode = tk.IntVar()
self.max_times = tk.IntVar()

self.watchdog_enable = tk.BooleanVar()
self.max_win_time = tk.IntVar()
Expand All @@ -29,6 +31,7 @@ def __init__(self, master=None):

self.run_mode.set(0)
self.run_submode.set(0)
self.max_times.set(0)
self.watchdog_enable.set(True)
self.max_win_time.set(100)
self.max_op_time.set(20)
Expand All @@ -53,6 +56,9 @@ def __init__(self, master=None):
self.create_frame2()
self.create_frame3()

# 创建次数菜单
self.create_times()

# 创建高级菜单
self.create_advance()

Expand Down Expand Up @@ -113,7 +119,7 @@ def create_section(self):
self.frame3 = tk.Frame(self.section)
self.section.add(self.frame3, text='关于')

self.section.pack(fill=tk.BOTH)
self.section.pack(fill=tk.BOTH, expand=True)

def create_frame0(self):
'''
Expand Down Expand Up @@ -169,11 +175,11 @@ def create_frame2(self):
'''
# 提示文本
textframe = tk.Frame(self.frame2)
textframe.pack(expand=True, fill=tk.X)
textframe.pack(expand=True, fill=tk.BOTH)
s = tk.Scrollbar(textframe)
s.pack(side=tk.RIGHT)
text = tk.Text(textframe, height=5, width=21)
text.pack(side=tk.LEFT, expand=True, fill=tk.X)
text.pack(side=tk.LEFT, expand=True, fill=tk.BOTH)
text.insert(tk.INSERT, '把狗粮队长放在最左边,点开需要打的章节,然后开始。\n')
text.insert(tk.INSERT, '支持自动换狗粮,只打经验怪。\n')
text.insert(tk.END, '最好把“合并相同式神”选项关闭。\n')
Expand Down Expand Up @@ -212,6 +218,22 @@ def create_frame3(self):
tk.END, '网址:https://github.com/AcademicDog/onmyoji_bot\n\n交流Q群:592055060')
text.config(state=tk.DISABLED)

def create_times(self):
'''
游戏次数
'''
times = tk.LabelFrame(self.main_frame1, text='次数设置')
times.pack(padx=5, fill=tk.X, anchor=tk.W)
timeframe1 = tk.Frame(times)
timeframe1.pack(anchor=tk.W)
tk.Label(timeframe1, text='游戏次数(0=无数次):').pack(side=tk.LEFT)
tk.Entry(timeframe1, width=6, textvariable=self.max_times).pack()
self.end_operation = ttk.Combobox(times)
self.end_operation['value'] = ('结束后关闭脚本', '结束后关闭脚本和游戏')
self.end_operation.pack(fill=tk.X, padx=2, pady=2)
self.end_operation.current(0)
self.end_operation.config(state='readonly')

def create_advance(self):
'''
高级菜单
Expand Down Expand Up @@ -260,6 +282,9 @@ def show_params(self):
self.params.insert(tk.END, '\nrun_mode: '+str(self.run_mode.get()))
self.params.insert(tk.END, '\nrun_submode: ' +
str(self.run_submode.get()))
self.params.insert(tk.END, '\nmax_times: ' + str(self.max_times.get()))
self.params.insert(tk.END, '\nend_operation: ' +
str(self.end_operation.current()))
self.params.insert(tk.END, '\nwatchdog_enable: ' +
str(self.watchdog_enable.get()))
self.params.insert(tk.END, '\nmax_win_time: ' +
Expand Down
Binary file added img/icon/OnmyojiBot.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions mitama/fighter_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,6 @@ def start(self):
time.sleep(0.2)
self.yys.mouse_click_bg((674, 384))
self.log.writeinfo('Driver: 自动邀请')

# 检查游戏次数
self.check_times()
3 changes: 3 additions & 0 deletions mitama/fighter_passenger.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ def start(self):
elif self.yys.find_game_img('img\\JIE-SHOU.png'):
self.yys.mouse_click_bg((125, yuhun_loc[1]))
self.log.writeinfo('Passenger: 接受邀请')

# 检查游戏次数
self.check_times()
4 changes: 4 additions & 0 deletions mitama/single_fight.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import tools.utilities as ut

import configparser
import logging


class SingleFight(Fighter):
Expand Down Expand Up @@ -54,3 +55,6 @@ def start(self):
self.click_until_knn('结算', 'img\\TIAO-ZHAN.png',
*CommonPos.second_position, mood3.get1mood()/1000, thread=20)
self.log.writeinfo("回到选择界面")

# 检查游戏次数
self.check_times()
8 changes: 8 additions & 0 deletions onmyoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def my_excepthook(exc_type, exc_value, tb):
sys.excepthook = my_excepthook
logging.info('UAC pass')

# Query DPI Awareness (Windows 10 and 8)
awareness = ctypes.c_int()
errorCode = ctypes.windll.shcore.GetProcessDpiAwareness(
0, ctypes.byref(awareness))

# Set DPI Awareness (Windows 10 and 8)
errorCode = ctypes.windll.shcore.SetProcessDpiAwareness(0)

# 设置战斗参数
init()

Expand Down
16 changes: 16 additions & 0 deletions ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def set_conf(self):

# 御魂参数
self.conf.set('DEFAULT', 'run_mode', str(self.run_mode.get()))
self.conf.set('DEFAULT', 'max_times', str(self.max_times.get()))
self.conf.set('DEFAULT', 'end_operation', str(self.end_operation.current()))
self.conf.set('mitama', 'run_submode', str(self.run_submode.get()))
self.conf.set('mitama', 'mitama_team_mark',
str(self.mitama_team_mark.current()))
Expand Down Expand Up @@ -111,6 +113,20 @@ def my_excepthook(exc_type, exc_value, tb):
if is_admin():
sys.excepthook = my_excepthook

# Query DPI Awareness (Windows 10 and 8)
awareness = ctypes.c_int()
errorCode = ctypes.windll.shcore.GetProcessDpiAwareness(
0, ctypes.byref(awareness))

# Set DPI Awareness (Windows 10 and 8)
errorCode = ctypes.windll.shcore.SetProcessDpiAwareness(1)
# the argument is the awareness level, which can be 0, 1 or 2:
# for 1-to-1 pixel control I seem to need it to be non-zero (I'm using level 2)

# Set DPI Awareness (Windows 7 and Vista)
success = ctypes.windll.user32.SetProcessDPIAware()
# behaviour on later OSes is undefined, although when I run it on my Windows 10 machine, it seems to work with effects identical to SetProcessDpiAwareness(1)

# 设置战斗参数
root = tk.Tk()
app = MyBattle(root)
Expand Down

0 comments on commit 76932cf

Please sign in to comment.