Skip to content

Commit 0fa89df

Browse files
authored
Merge pull request #813 from runhey/dev
Automated PR 2025.04.03
2 parents aac67f5 + dda17fb commit 0fa89df

File tree

15 files changed

+58
-49
lines changed

15 files changed

+58
-49
lines changed

module/atom/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def load_image(self) -> None:
7474
if height != self.roi_front[3] or width != self.roi_front[2]:
7575
self.roi_front[2] = width
7676
self.roi_front[3] = height
77-
logger.info(f"{self.name} roi_front size changed to {width}x{height}")
77+
logger.debug(f"{self.name} roi_front size changed to {width}x{height}")
7878

7979
def load_kp_des(self) -> None:
8080
if self._kp is not None and self._des is not None:
-1.1 KB
Loading

tasks/DailyTrifles/assets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DailyTriflesAssets:
3333
# 礼包屋
3434
I_ROOM_GIFT = RuleImage(roi_front=(1152,644,52,53), roi_back=(1127,611,103,94), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_room_gift.png")
3535
# description
36-
I_GIFT_RECOMMEND = RuleImage(roi_front=(1186,98,53,64), roi_back=(1172,83,83,306), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_recommend.png")
36+
I_GIFT_RECOMMEND = RuleImage(roi_front=(1186,98,53,64), roi_back=(1172,83,83,306), threshold=0.7, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_recommend.png")
3737
# 免费一抽
3838
I_GIFT_SIGN = RuleImage(roi_front=(236,129,306,218), roi_back=(236,129,306,218), threshold=0.8, method="Template matching", file="./tasks/DailyTrifles/store/store_gift_sign.png")
3939
# 体力

tasks/DailyTrifles/store/image.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"roiFront": "1186,98,53,64",
1515
"roiBack": "1172,83,83,306",
1616
"method": "Template matching",
17-
"threshold": 0.8,
17+
"threshold": 0.7,
1818
"description": "description"
1919
},
2020
{

tasks/Dokan/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ class DokanConfig(BaseModel):
144144
# 道馆系数,赏金/人数 根据喜好配置
145145
find_dokan_score: float = Field(default=4.6, description='dokan_score_help')
146146

147+
# 道馆最小人数限制
148+
min_people_num: int = Field(default=-1, description='min_people_num_help')
149+
150+
# 最少赏金设置
151+
min_bounty: int = Field(default=0, description='min_bounty_help')
152+
147153
# 单次查找道馆时,最大刷新次数.超过此次数后,若还未找到符合要求的,会随机选择一个道馆
148154
find_dokan_refresh_count: int = Field(default=7, description='find_dokan_refresh_count_help')
149155

tasks/Dokan/script_task.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ def run(self):
9090
out_dokan_timer = Timer(60)
9191
if not in_dokan:
9292
out_dokan_timer.start()
93-
if not self.goto_dokan_map():
94-
logger.warning("dokan didn`t started")
95-
is_dokan_activated = False
93+
self.goto_dokan_scene()
9694

9795
# 是否已击败馆主第一阵容
9896
first_master_killed = False
@@ -130,15 +128,22 @@ def run(self):
130128

131129
# 场景状态:寻找合适道馆中
132130
if current_scene == DokanScene.RYOU_DOKAN_SCENE_FINDING_DOKAN:
133-
# NOTE 只在周一尝试建立道馆
134-
if datetime.now().weekday() == 0:
135-
self.creat_dokan()
136131

137132
# 更新可挑战次数 可挑战次数为<=0,当作道馆成功完成
138133
count = self.update_remain_attack_count()
139134
if count <= 0:
140135
is_dokan_activated = True
141136
break
137+
138+
# 如果没有权限,道馆还未开启
139+
try_start_dokan = self.config.dokan.dokan_config.try_start_dokan
140+
if not try_start_dokan:
141+
is_dokan_activated = False
142+
break
143+
# NOTE 只在周一尝试建立道馆
144+
if datetime.now().weekday() == 0:
145+
self.creat_dokan()
146+
142147
# 寻找合适道馆,找不到直接退出
143148
if not self.find_dokan(self.config.dokan.dokan_config.find_dokan_score):
144149
is_dokan_activated = False
@@ -191,6 +196,7 @@ def run(self):
191196
continue
192197
# 场景状态:检查右下角有没有挑战?通常是失败了,并退出来到集结界面,可重新开始点击右下角挑战进入战斗
193198
if current_scene == DokanScene.RYOU_DOKAN_SCENE_START_CHALLENGE:
199+
self.switch_soul_in_dokan()
194200
self.click(self.I_RYOU_DOKAN_START_CHALLENGE, interval=1)
195201
continue
196202
# 场景状态:馆主第一阵容 且战斗未开始
@@ -511,30 +517,15 @@ def goto_main(self):
511517
self.click(self.I_BACK_Y, interval=3)
512518
continue
513519

514-
def goto_dokan_map(self):
515-
"""
516-
任意场景进入道馆地图
517-
# 有权限开启道馆 - 通过神社进入道馆地图
518-
# 没有权限开启道馆 - 判断阴阳寮界面左侧的已开启活动列表是否存在道馆
519-
"""
520-
try_start_dokan = self.config.dokan.dokan_config.try_start_dokan
520+
def goto_dokan_scene(self):
521+
# 截图速度太快会导致在道馆-神社之间一直循环无法退出,故设置截图间隔
522+
self.device.screenshot_interval_set(0.3)
521523
while 1:
522524
self.screenshot()
523525
in_dokan, cur_scene = self.get_current_scene()
524526
if in_dokan:
525-
return True
527+
break
526528
if cur_scene == DokanScene.RYOU_DOKAN_RYOU:
527-
if not try_start_dokan:
528-
# 等待左侧活动列表弹出
529-
self.wait_until_stable(self.I_RYOU_DOKAN_ACTIVATED, Timer(0.5, 2), Timer(5, 10))
530-
531-
# 尝试通过已开启活动列表中查找道馆
532-
if self.appear(self.I_RYOU_DOKAN_ACTIVATED):
533-
self.ui_click_until_disappear(self.I_RYOU_DOKAN_ACTIVATED)
534-
return True
535-
# 在已开启活动列表中 没有找到道馆
536-
logger.error(f"can not find dokan in activated list,FAILED")
537-
return False
538529
self.ui_click_until_disappear(self.I_RYOU_SHENSHE)
539530
continue
540531
if cur_scene == DokanScene.RYOU_DOKAN_SHENSHE:
@@ -544,6 +535,8 @@ def goto_dokan_map(self):
544535
self.ui_get_current_page()
545536
self.ui_goto(page_guild)
546537
continue
538+
self.device.screenshot_interval_set()
539+
return True
547540

548541
def enter_dokan(self):
549542
"""
@@ -671,6 +664,12 @@ def find_challengeable(ignore_score=False):
671664
if item_score > score or item_score < 1.5:
672665
logger.info("click to making challenge disappear")
673666
continue
667+
if p_num < self.config.dokan.dokan_config.min_people_num:
668+
logger.info("people num too small")
669+
continue
670+
if bounty < self.config.dokan.dokan_config.min_bounty:
671+
logger.info("bounty too small")
672+
continue
674673
# 馆主不是修习等级的
675674
if not self.appear(self.I_CENTER_GUANZHU_XIUXI):
676675
continue
@@ -889,13 +888,14 @@ def next_run(self, skip_today=False, is_dokan_activated=False):
889888
# 道馆没有开启
890889
now = datetime.now()
891890
ser_time: Time = self.config.dokan.scheduler.server_update
891+
ser_time = datetime.combine(now.date(), ser_time)
892892
if not is_dokan_activated:
893893
# 在服务器时间之前,设置为服务器时间
894-
if now.hour < ser_time.hour or (now.hour == ser_time.hour and now.minute < ser_time.minute):
894+
if now < ser_time:
895895
self.set_next_run(task="Dokan", target=now.replace(hour=ser_time.hour, minute=ser_time.minute))
896896
return
897897
# 在服务器时间之后,如超过两小时,则直接当作成功;未超过则当作失败
898-
if now.hour - ser_time.hour > 2:
898+
if now - ser_time > timedelta(hours=2):
899899
self.set_next_run(task="Dokan", finish=False, success=True, server=True)
900900
return
901901
# 时间在道馆开启时间附近,3分钟后执行

tasks/RichMan/assets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class RichManAssets:
267267

268268
# Ocr Rule Assets
269269
# 蛇皮剩余可买的
270-
O_SCA_NUMBER_OROCHI = RuleOcr(roi=(46,318,27,25), area=(46,318,27,25), mode="Quantity", method="Default", keyword="", name="sca_number_orochi")
270+
O_SCA_NUMBER_OROCHI = RuleOcr(roi=(46,318,30,25), area=(46,318,30,25), mode="Quantity", method="Default", keyword="", name="sca_number_orochi")
271271
# 首领御魂剩余可买的
272272
O_SCA_NUMBER_DEMON = RuleOcr(roi=(627,319,30,25), area=(627,319,30,25), mode="Quantity", method="Default", keyword="", name="sca_number_demon")
273273
# 永生之海

tasks/RichMan/mall/scales/ocr.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[
22
{
33
"itemName": "sca_number_orochi",
4-
"roiFront": "46,318,27,25",
5-
"roiBack": "46,318,27,25",
4+
"roiFront": "46,318,30,25",
5+
"roiBack": "46,318,30,25",
66
"mode": "Quantity",
77
"method": "Default",
88
"keyword": "",

tasks/Secret/script_task.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from tasks.Component.GeneralBuff.config_buff import BuffClass
2121
from tasks.WeeklyTrifles.assets import WeeklyTriflesAssets
2222

23+
2324
class ScriptTask(GameUi, GeneralBattle, SwitchSoul, SecretAssets):
2425
lay_list = ['壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾']
2526

@@ -35,7 +36,9 @@ def match_layer(self) -> dict:
3536

3637
@cached_property
3738
def battle_config(self) -> GeneralBattleConfig:
38-
return GeneralBattleConfig()
39+
conf = self.config.model.secret.general_battle
40+
conf.lock_team_enable = False
41+
return conf
3942

4043
def run(self):
4144
self.check_time()
@@ -134,14 +137,16 @@ def run(self):
134137
self.set_next_run(task='Secret', success=True, finish=True)
135138
raise TaskEnd('Secret')
136139

137-
def find_battle(self, screenshot: bool=False) -> int or None:
140+
def find_battle(self, screenshot: bool = False) -> int or None:
138141
"""
139142
自动寻找挑战的层数并且选定 , 找不到会向下划一点
140143
:return: 如果找得到返回层数,找不到返回None
141144
"""
145+
142146
def set_layer_roi(ocr_target: RuleOcr, roi: tuple):
143147
ocr_target.roi[0] = int(roi[0]) - 225
144148
ocr_target.roi[1] = int(roi[1]) - 40
149+
145150
def check_layer(ocr_target: RuleOcr, roi=None) -> int or None:
146151
#
147152
# 手动留了一个bug: 即使匹配到了未通关 但是在判断层数的时候还是会先判断第一个是什么的
@@ -199,7 +204,6 @@ def confirm_layer(ocr_target: RuleOcr, roi=None) -> int or None:
199204
logger.warning(f'OCR failed, try again {jade_num}')
200205
return None
201206

202-
203207
if screenshot:
204208
self.screenshot()
205209
if self.appear(self.I_CHAT_CLOSE_BUTTON):
@@ -286,6 +290,7 @@ def check_time(self) -> None:
286290
if __name__ == '__main__':
287291
from module.config.config import Config
288292
from module.device.device import Device
293+
289294
c = Config('oas1')
290295
d = Device(c)
291296
t = ScriptTask(c, d)

tasks/SoulsTidy/assets.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class SoulsTidyAssets:
1212

1313
# Click Rule Assets
1414
# 御魂详细
15-
C_ST_DETAIL = RuleClick(roi_front=(1189,321,87,74), roi_back=(1189,321,87,74), name="st_detail")
15+
C_ST_DETAIL = RuleClick(roi_front=(1188,318,87,74), roi_back=(1190,317,87,74), name="st_detail")
1616
# 出现神赐
1717
C_ST_GOD_PRSENT = RuleClick(roi_front=(717,165,100,48), roi_back=(926,165,100,54), name="st_god_prsent")
1818

@@ -43,7 +43,7 @@ class SoulsTidyAssets:
4343
# 神赐
4444
I_ST_GOD_PRESENT = RuleImage(roi_front=(578,234,131,73), roi_back=(542,117,204,219), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_god_present.png")
4545
# 已弃置被选中
46-
I_ST_ABANDONED_SELECTED = RuleImage(roi_front=(20,110,140,50), roi_back=(20,110,140,50), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_abandoned_selected.png")
46+
I_ST_ABANDONED_SELECTED = RuleImage(roi_front=(47,118,84,33), roi_back=(45,119,85,34), threshold=0.8, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_abandoned_selected.png")
4747
# 第一个御魂是+0的
4848
I_ST_LEVEL_0 = RuleImage(roi_front=(85,235,45,30), roi_back=(85,235,45,30), threshold=0.9, method="Template matching", file="./tasks/SoulsTidy/simple/simple_st_level_0.png")
4949
# 御魂奉纳后获得的金币

0 commit comments

Comments
 (0)