Skip to content

Commit a0b3146

Browse files
authored
Merge pull request #774 from ljxun/dev_switchsoul
refactor(Component/SwitchSoul): 优化式神录切换操作- 调整了多个图像资源的 ROI 区域,提高匹配准确性
2 parents 916556c + e8d32bc commit a0b3146

File tree

9 files changed

+30
-17
lines changed

9 files changed

+30
-17
lines changed

tasks/Component/SwitchSoul/assets.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ class SwitchSoulAssets:
3333
# 退出式神录
3434
I_RECORD_SOUL_BACK = RuleImage(roi_front=(19,9,51,44), roi_back=(19,9,51,44), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_record_soul_back.png")
3535
# 预设
36-
I_SOUL_PRESET = RuleImage(roi_front=(332,70,90,51), roi_back=(332,70,90,51), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_soul_preset.png")
36+
I_SOUL_PRESET = RuleImage(roi_front=(335,73,90,51), roi_back=(310,57,169,72), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_soul_preset.png")
3737
# description
38-
I_SOU_SWITCH_1 = RuleImage(roi_front=(971,148,37,35), roi_back=(971,148,37,35), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_1.png")
38+
I_SOU_SWITCH_1 = RuleImage(roi_front=(971,149,34,32), roi_back=(962,141,51,48), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_1.png")
3939
# description
40-
I_SOU_SWITCH_2 = RuleImage(roi_front=(978,304,27,29), roi_back=(978,304,27,29), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_2.png")
40+
I_SOU_SWITCH_2 = RuleImage(roi_front=(967,296,42,39), roi_back=(961,292,54,49), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_2.png")
4141
# description
42-
I_SOU_SWITCH_3 = RuleImage(roi_front=(973,454,26,26), roi_back=(973,454,26,26), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_3.png")
42+
I_SOU_SWITCH_3 = RuleImage(roi_front=(968,448,41,38), roi_back=(962,442,52,48), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_3.png")
4343
# description
44-
I_SOU_SWITCH_4 = RuleImage(roi_front=(971,600,37,26), roi_back=(971,600,37,26), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_4.png")
44+
I_SOU_SWITCH_4 = RuleImage(roi_front=(967,597,42,25), roi_back=(962,592,53,34), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_4.png")
4545
# description
4646
I_SOU_SWITCH_SURE = RuleImage(roi_front=(668,401,180,61), roi_back=(668,401,180,61), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_switch_sure.png")
4747
# 用于判断是否在式神录里面
@@ -64,6 +64,8 @@ class SwitchSoulAssets:
6464
I_SOU_TEAM_PRESENT = RuleImage(roi_front=(737,82,148,43), roi_back=(727,71,165,63), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_team_present.png")
6565
# 需要切换的预设按钮(颜色深一点)
6666
I_SOU_CLICK_PRESENT = RuleImage(roi_front=(967,305,43,22), roi_back=(965,142,48,480), threshold=0.9, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_sou_click_present.png")
67+
# 误触点到式神检查
68+
I_CHECK_BLOCK = RuleImage(roi_front=(572,408,137,49), roi_back=(572,408,137,49), threshold=0.8, method="Template matching", file="./tasks/Component/SwitchSoul/ss/ss_check_block.png")
6769

6870

6971
# Ocr Rule Assets

tasks/Component/SwitchSoul/ss/image.json

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,44 +11,44 @@
1111
{
1212
"itemName": "soul_preset",
1313
"imageName": "ss_soul_preset.png",
14-
"roiFront": "332,70,90,51",
15-
"roiBack": "332,70,90,51",
14+
"roiFront": "335,73,90,51",
15+
"roiBack": "310,57,169,72",
1616
"method": "Template matching",
1717
"threshold": 0.8,
1818
"description": "预设"
1919
},
2020
{
2121
"itemName": "sou_switch_1",
2222
"imageName": "ss_sou_switch_1.png",
23-
"roiFront": "971,148,37,35",
24-
"roiBack": "971,148,37,35",
23+
"roiFront": "971,149,34,32",
24+
"roiBack": "962,141,51,48",
2525
"method": "Template matching",
2626
"threshold": 0.8,
2727
"description": "description"
2828
},
2929
{
3030
"itemName": "sou_switch_2",
3131
"imageName": "ss_sou_switch_2.png",
32-
"roiFront": "978,304,27,29",
33-
"roiBack": "978,304,27,29",
32+
"roiFront": "967,296,42,39",
33+
"roiBack": "961,292,54,49",
3434
"method": "Template matching",
3535
"threshold": 0.8,
3636
"description": "description"
3737
},
3838
{
3939
"itemName": "sou_switch_3",
4040
"imageName": "ss_sou_switch_3.png",
41-
"roiFront": "973,454,26,26",
42-
"roiBack": "973,454,26,26",
41+
"roiFront": "968,448,41,38",
42+
"roiBack": "962,442,52,48",
4343
"method": "Template matching",
4444
"threshold": 0.8,
4545
"description": "description"
4646
},
4747
{
4848
"itemName": "sou_switch_4",
4949
"imageName": "ss_sou_switch_4.png",
50-
"roiFront": "971,600,37,26",
51-
"roiBack": "971,600,37,26",
50+
"roiFront": "967,597,42,25",
51+
"roiBack": "962,592,53,34",
5252
"method": "Template matching",
5353
"threshold": 0.8,
5454
"description": "description"
@@ -151,5 +151,14 @@
151151
"method": "Template matching",
152152
"threshold": 0.9,
153153
"description": "需要切换的预设按钮(颜色深一点)"
154+
},
155+
{
156+
"itemName": "check_block",
157+
"imageName": "ss_check_block.png",
158+
"roiFront": "572,408,137,49",
159+
"roiBack": "572,408,137,49",
160+
"method": "Template matching",
161+
"threshold": 0.8,
162+
"description": "误触点到式神检查"
154163
}
155164
]
3.46 KB
Loading
-281 Bytes
Loading
1.79 KB
Loading
1.99 KB
Loading
191 Bytes
Loading
344 Bytes
Loading

tasks/Component/SwitchSoul/switch_soul.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_team_asset(team: int):
100100
break
101101
cur_text = ocr_text
102102
# 向上滑动
103-
self.swipe(self.S_SS_GROUP_SWIPE_UP, 0.5)
103+
self.swipe(self.S_SS_GROUP_SWIPE_UP, 1.5)
104104
# 等待滑动动画
105105
sleep(0.5)
106106

@@ -129,10 +129,12 @@ def get_team_asset(team: int):
129129
while 1:
130130
self.click(self.I_SOU_SWITCH_SURE, 3)
131131
self.screenshot()
132+
if self.appear_then_click(self.I_CHECK_BLOCK, 3):
133+
continue
132134
if not self.appear(self.I_SOU_SWITCH_SURE):
133135
break
134136
continue
135-
if not self.appear_then_click(target_team, interval=1):
137+
if not self.appear_then_click(target_team, interval=3):
136138
logger.warning(f'Click team {team} failed in group {group}')
137139

138140
logger.info(f'Switch soul_one group {group} team {team}')

0 commit comments

Comments
 (0)