Skip to content

Commit

Permalink
1.0.1.0301
Browse files Browse the repository at this point in the history
  • Loading branch information
AcademicDog committed Mar 1, 2020
1 parent 79f39c1 commit 2de3dc6
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 40 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## v1.0.1.0301
#### New features:
* 增加延迟设定选项。
#### Fixes (bugs & defects):
* 根据[#48](https://github.com/AcademicDog/onmyoji_bot/issues/48),优化了御魂司机的标记。

## v1.0.1.0229
#### New features:
* 增加了更详细的调试信息显示。
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion gameLib/fighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def mitama_team_click(self):
# 点击指定位置并等待下一轮
self.yys.mouse_click_bg(*pos)
self.log.writeinfo(self.name + '标记式神')
time.sleep(0.4)
ut.mysleep(500)

self.log.writewarning(self.name + '标记式神失败')

Expand Down
73 changes: 52 additions & 21 deletions gui/tkui.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import tkinter as tk
import tkinter.messagebox
from tkinter import ttk
Expand Down Expand Up @@ -340,50 +341,80 @@ def __init__(self, parent):
self.title('延迟设置')
self.parent = parent

# 参数
self.delay = {
1: [tk.IntVar(value=1000), tk.IntVar(value=1500)],
2: [tk.IntVar(value=1300), tk.IntVar(value=2100)],
3: [tk.IntVar(value=1800), tk.IntVar(value=3000)],
4: [tk.IntVar(value=2500), tk.IntVar(value=4000)],
5: [tk.IntVar(value=3000), tk.IntVar(value=5000)]}

# 延迟机制
row1 = tk.Frame(self)
row1.pack(fill=tk.X)
tk.Label(row1, text='延迟机制:').pack(anchor=tk.W)
text = tk.Text(row1, height=8, width=40)
text = tk.Text(row1, height=11, width=40)
text.pack(expand=True, fill=tk.BOTH)
text.insert(tk.INSERT, '1-总共5级延迟,脚本随机从1-5级延迟中选择一级作为主延迟,\
同时在1-3级延迟中选择一级作为副延迟。\n\n')
text.insert(tk.INSERT, '2-每5分钟刷新选择,计算单位毫秒。\n\n')
text.insert(tk.END, '1-总共5级延迟,脚本随机从1-5级延迟中选择一级作为主延迟,\
同时在1-3级延迟中选择一级作为副延迟。在此基础上乘以随机系数。\n\n')
text.insert(tk.END, '2-每5分钟刷新选择,计算单位毫秒。\n\n')
text.insert(tk.END, '3-主延迟用于截图、识图等一般操作的延迟,副延迟主要用于结算。\n\n')
text.insert(tk.END, '4-不要纠结为什么每次重开这个表格都不变,参数存在delay.json。\n\n')
text.config(state=tk.DISABLED)

# 参数设置
row2 = tk.Frame(self)
row2.pack(fill=tk.X)
tk.Label(row2, text='一级: ').grid(row=0, column=0)
tk.Label(row2, text='最低').grid(row=0, column=1)
tk.Entry(row2, width=7).grid(row=0, column=3)
tk.Entry(row2, width=7, textvariable=self.delay[1][0]).grid(row=0, column=3)
tk.Label(row2, text='最高').grid(row=0, column=4)
tk.Entry(row2, width=7).grid(row=0, column=5)
tk.Entry(row2, width=7, textvariable=self.delay[1][1]).grid(row=0, column=5)

tk.Label(row2, text='二级: ').grid(row=1, column=0)
tk.Label(row2, text='最低').grid(row=1, column=1)
tk.Entry(row2, width=7, textvariable=self.delay[2][0]).grid(row=1, column=3)
tk.Label(row2, text='最高').grid(row=1, column=4)
tk.Entry(row2, width=7, textvariable=self.delay[2][1]).grid(row=1, column=5)

tk.Label(row2, text='二级: ').grid(row=2, column=0)
tk.Label(row2, text='三级: ').grid(row=2, column=0)
tk.Label(row2, text='最低').grid(row=2, column=1)
tk.Entry(row2, width=7).grid(row=2, column=3)
tk.Entry(row2, width=7, textvariable=self.delay[3][0]).grid(row=2, column=3)
tk.Label(row2, text='最高').grid(row=2, column=4)
tk.Entry(row2, width=7).grid(row=2, column=5)
tk.Entry(row2, width=7, textvariable=self.delay[3][1]).grid(row=2, column=5)

tk.Label(row2, text='三级: ').grid(row=3, column=0)
tk.Label(row2, text='四级: ').grid(row=3, column=0)
tk.Label(row2, text='最低').grid(row=3, column=1)
tk.Entry(row2, width=7).grid(row=3, column=3)
tk.Entry(row2, width=7, textvariable=self.delay[4][0]).grid(row=3, column=3)
tk.Label(row2, text='最高').grid(row=3, column=4)
tk.Entry(row2, width=7).grid(row=3, column=5)
tk.Entry(row2, width=7, textvariable=self.delay[4][1]).grid(row=3, column=5)

tk.Label(row2, text='四级: ').grid(row=4, column=0)
tk.Label(row2, text='五级: ').grid(row=4, column=0)
tk.Label(row2, text='最低').grid(row=4, column=1)
tk.Entry(row2, width=7).grid(row=4, column=3)
tk.Entry(row2, width=7, textvariable=self.delay[5][0]).grid(row=4, column=3)
tk.Label(row2, text='最高').grid(row=4, column=4)
tk.Entry(row2, width=7).grid(row=4, column=5)

tk.Label(row2, text='五级: ').grid(row=5, column=0)
tk.Label(row2, text='最低').grid(row=5, column=1)
tk.Entry(row2, width=7).grid(row=5, column=3)
tk.Label(row2, text='最高').grid(row=5, column=4)
tk.Entry(row2, width=7).grid(row=5, column=5)
tk.Entry(row2, width=7, textvariable=self.delay[5][1]).grid(row=4, column=5)

# 按钮
row3 = tk.Frame(self)
row3.pack(anchor=tk.E)
tk.Button(row3, text='确定', command=self.confirm).grid(row=0, column=0)
tk.Button(row3, text='取消', command=self.cancel).grid(row=0, column=1)

def confirm(self):
mydelay ={
1: [self.delay[1][0].get(), self.delay[1][1].get() - self.delay[1][0].get()],
2: [self.delay[2][0].get(), self.delay[2][1].get() - self.delay[2][0].get()],
3: [self.delay[3][0].get(), self.delay[3][1].get() - self.delay[3][0].get()],
4: [self.delay[4][0].get(), self.delay[4][1].get() - self.delay[4][0].get()],
5: [self.delay[5][0].get(), self.delay[5][1].get() - self.delay[5][0].get()]}
jsObj = json.dumps(mydelay)
with open('delay.json', 'w') as f:
f.write(jsObj)
self.destroy()

def cancel(self):
self.destroy()

if __name__ == "__main__":
root = tk.Tk()
Expand Down
4 changes: 3 additions & 1 deletion mitama/fighter_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def start(self):
self.log.writeinfo('Driver: 点击开始战斗按钮')
self.click_until('开始战斗按钮', 'img\\KAI-SHI-ZHAN-DOU.png', *
YuhunPos.kaishizhandou_btn, mood2.get1mood()/1000, False)
self.log.writeinfo('Driver: 已进入战斗')

# 检测是否进入战斗
self.check_battle()

# 在战斗中,标记己方式神
self.mitama_team_click()
Expand Down
59 changes: 43 additions & 16 deletions tools/utilities.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import json
import logging
import random
import time

from tools.logsystem import WriteLog

log = WriteLog()


class Mood:
'''
Expand All @@ -15,26 +13,58 @@ class Mood:
tired: 状态疲劳,点击延迟在2.5-4\n
exhausted: CHSM,点击延迟在3-5s\n
'''
__first_init = True

def __init__(self, state=5):
self.lastime = time.time()
self.state = state
if Mood.__first_init:
self.read_config()
Mood.__first_init = False
a = random.randint(1, self.state)
logging.info("创建延迟参数,等级: %d", a)
self.lastmood = Mood.mymood[a]

def read_config(self):
try:
# 读取延迟配置
with open('delay.json', 'r') as f:
fileObject = f.read()
jsObj = json.loads(fileObject)
logging.info('读取延迟配置文件成功')
Mood.mymood = {
1: (jsObj['1'][0], jsObj['1'][1]),
2: (jsObj['2'][0], jsObj['2'][1]),
3: (jsObj['3'][0], jsObj['3'][1]),
4: (jsObj['4'][0], jsObj['4'][1]),
5: (jsObj['5'][0], jsObj['5'][1])}
except FileNotFoundError:
# 文件未找到
logging.info('使用默认延迟参数')
self.set_default()
except:
# 其他错误
logging.warning('延迟配置文件错误,使用默认参数')
self.set_default()
logging.info('延迟参数: '+str(Mood.mymood))

def set_default(self):
'''
设置默认延迟参数
'''
Mood.mymood = {
1: (1000, 500),
2: (1300, 800),
3: (1800, 1200),
4: (2500, 1500),
5: (3000, 2000)}
a = random.randint(1, self.state)
log.writeinfo("Now you mood is level %d", a)
self.lastmood = Mood.mymood[a]

def getmood(self):
if (time.time() - self.lastime >= 300):
self.lastime = time.time()
a = random.randint(1, self.state)
self.lastmood = Mood.mymood[a]
log.writeinfo("Now you mood is level %d", a)
logging.info("修改延迟参数,等级 %d", a)
return self.lastmood

def moodsleep(self):
Expand Down Expand Up @@ -63,14 +93,6 @@ def secondposition():
:return: 返回随机位置坐标
'''
return (random.randint(887, 1111), random.randint(56, 452))
'''
while True:
position = (random.randint(0, w), random.randint(50, h - 90))
if position[0] < 180 or position[0] > 956:
return position
elif position[1] < 112:
return position
'''


def mysleep(slpa, slpb=0):
Expand All @@ -83,3 +105,8 @@ def mysleep(slpa, slpb=0):
else:
slp = random.randint(slpa, slpa+slpb)
time.sleep(slp/1000)


if __name__ == "__main__":
mood = Mood()
print(Mood.mymood)

0 comments on commit 2de3dc6

Please sign in to comment.