Просмотр исходного кода

feat(Exploration):选关改为在主线 tab 下进行,新增 tab 页导航

- 新增 page_mainline/page_gameplay 两个 tab 页,并从 hub 继承全部转移边
- pre_process 与 open_expect_level 改为 goto_page(page_mainline)
- assets.py / res 新增主线、玩法 tab 的检测模板与点击规则
User 1 месяц назад
Родитель
Сommit
c56e2c9b8f

+ 8 - 0
tasks/Exploration/assets.py

@@ -68,6 +68,10 @@ class ExplorationAssets:
 	C_CLICK_ROTATE_4 = RuleClick(roi_front=(921,590,21,21), roi_back=(921,590,21,21), name="click_rotate_4")
 	# 随机点 
 	C_SAFE_RANDOM = RuleClick(roi_front=(0,0,111,12), roi_back=(0,0,111,12), name="safe_random")
+	# 探索大地图 · 主线 tab 标题("章"字锚点)点击区域 
+	C_CLICK_MAIN_TITLE = RuleClick(roi_front=(1070,174,77,28), roi_back=(1070,174,77,28), name="click_main_title")
+	# 探索大地图 · 玩法 tab 标题("御魂"标题锚点)点击区域 
+	C_CLICK_PALY_TITLE = RuleClick(roi_front=(1178,172,77,28), roi_back=(1178,172,77,28), name="click_paly_title")
 
 
 	# Image Rule Assets
@@ -127,6 +131,10 @@ class ExplorationAssets:
 	I_EXP_ARROW_LEFT = RuleImage(roi_front=(1244,115,18,26), roi_back=(1178,78,100,100), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_exp_arrow_left.png")
 	# 战斗中的队友标识 
 	I_TEAM_EMOJI_FIGHT = RuleImage(roi_front=(38,405,37,37), roi_back=(18,386,74,75), threshold=0.8, method="Template matching", file="./tasks/Exploration/res/res_team_emoji_fight.png")
+	# 探索大地图 · 主线 tab 标题锚点("章"字,仅主线 tab 命中,玩法 tab 不命中) 
+	I_CHECK_MAIN_TITLE = RuleImage(roi_front=(1150,457,32,32), roi_back=(1069,222,113,336), threshold=0.85, method="Template matching", file="./tasks/Exploration/res/res_check_main_title.png")
+	# 探索大地图 · 玩法 tab 标题锚点("御魂"标题,仅玩法 tab 命中,主线 tab 不命中) 
+	I_CHECK_PLAY_TITLE = RuleImage(roi_front=(1073,214,40,32), roi_back=(1065,210,190,316), threshold=0.85, method="Template matching", file="./tasks/Exploration/res/res_check_play_title.png")
 
 
 	# Long Click Rule Assets

+ 10 - 3
tasks/Exploration/base.py

@@ -16,7 +16,8 @@ from tasks.Exploration.assets import ExplorationAssets
 from tasks.Exploration.config import ChooseRarity, AutoRotate, AttackNumber, UpType
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.GameUi.game_ui import GameUi
-from tasks.GameUi.page import page_exploration, page_shikigami_records, page_main
+from tasks.GameUi.page import page_shikigami_records, page_main
+import tasks.Exploration.page as pages
 from tasks.RealmRaid.script_task import ScriptTask as RealmRaidScriptTask
 from tasks.Utils.config_enum import ShikigamiClass
 
@@ -112,8 +113,9 @@ class BaseExploration(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, Replace
                 self.exp_100()
             self.close_buff()
 
-        # 探索页面
-        self.goto_page(page_exploration)
+        # 探索页面(大地图始终处于主线/玩法 tab 之一,裸 page_exploration 永远被 prio 60 的 tab 页遮蔽、
+        # 无法作为当前页抵达,故直接进入主线 tab)
+        self.goto_page(pages.page_mainline)
 
     def post_process(self):
         self.wait_until_stable(self.I_UI_BACK_RED)
@@ -133,6 +135,11 @@ class BaseExploration(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, Replace
 
     # 打开指定的章节:
     def open_expect_level(self):
+        # 选关依赖主线 tab 右侧的章节列表(I_E_EXPLORATION_CLICK + 章节名 OCR)。
+        # 探索大地图常驻「主线/玩法」之一,若停在玩法 tab 不选回主线,右边会是御魂/今日掉落等模块名,
+        # I_E_EXPLORATION_CLICK 不出现、OCR 交集为空 → 一直滑屏卡死。故进选关前无条件确保主线 tab。
+        self.goto_page(pages.page_mainline)
+
         swipeCount = 0
         while 1:
             # 探索的 config

+ 44 - 0
tasks/Exploration/page.py

@@ -0,0 +1,44 @@
+from tasks.Exploration.assets import ExplorationAssets
+from tasks.GameUi.assets import GameUiAssets
+from tasks.GameUi.page import all_of, page_exploration
+from tasks.GameUi.page_definition import Page
+
+
+def inherit_transitions(source: Page, *targets: Page) -> None:
+    """把 source 的全部出边复制给 targets(tab 页继承大地图出口,动作与 tab 状态无关)。
+
+    跳过目标页自身(自环防护),若目标页已有到同一目的地的边则不重复添加。
+    """
+    for target in targets:
+        for transition in source.transitions:
+            if transition.destination == target:
+                continue
+            if any(item.destination == transition.destination for item in target.transitions):
+                continue
+            target.connect(
+                transition.destination,
+                transition.action,
+                cost=transition.cost,
+                on_enter_success=transition.on_enter_success,
+                on_enter_failure=transition.on_enter_failure,
+                on_leave_success=transition.on_leave_success,
+                on_leave_failure=transition.on_leave_failure,
+            )
+
+
+# 探索大地图 · 主线 tab("章"字锚点,优先级高于 page_exploration 的兜底识别)
+page_mainline = Page(all_of(GameUiAssets.I_CHECK_EXPLORATION, ExplorationAssets.I_CHECK_MAIN_TITLE), priority=60)
+# 探索大地图 · 玩法 tab("御魂"标题锚点)
+page_gameplay = Page(all_of(GameUiAssets.I_CHECK_EXPLORATION, ExplorationAssets.I_CHECK_PLAY_TITLE), priority=60)
+
+# 大地图 tab 互切(固定坐标点击,幂等)
+page_mainline.connect(page_gameplay, ExplorationAssets.C_CLICK_PALY_TITLE, key="page_mainline->page_gameplay")
+page_gameplay.connect(page_mainline, ExplorationAssets.C_CLICK_MAIN_TITLE, key="page_gameplay->page_mainline")
+
+# 大地图通用态 -> tab 桥接边:page_exploration 是入口桥 + 导航缓存页,
+# tab 页必须从这里可达才能从庭院方向进入,也保证 tab 页能切回通用态。
+page_exploration.connect(page_mainline, ExplorationAssets.C_CLICK_MAIN_TITLE, key="page_exploration->page_mainline")
+page_exploration.connect(page_gameplay, ExplorationAssets.C_CLICK_PALY_TITLE, key="page_exploration->page_gameplay")
+
+# tab 页继承大地图全部出口(回庭院、各区域入口等),此后 page_exploration 新增出边自动跟随
+inherit_transitions(page_exploration, page_mainline, page_gameplay)

+ 12 - 0
tasks/Exploration/res/click.json

@@ -52,5 +52,17 @@
     "roiFront": "0,0,111,12",
     "roiBack": "0,0,111,12",
     "description": "随机点"
+  },
+  {
+    "itemName": "click_main_title",
+    "roiFront": "1070,174,77,28",
+    "roiBack": "1070,174,77,28",
+    "description": "点击探索大地图主线tab标题"
+  },
+  {
+    "itemName": "click_paly_title",
+    "roiFront": "1178,172,77,28",
+    "roiBack": "1178,172,77,28",
+    "description": "点击探索大地图玩法tab标题"
   }
 ]

+ 18 - 0
tasks/Exploration/res/image.json

@@ -250,5 +250,23 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "探索章节切换文件夹图标(移植自mine)"
+  },
+  {
+    "itemName": "check_main_title",
+    "imageName": "res_check_main_title.png",
+    "roiFront": "1150,457,32,32",
+    "roiBack": "1069,222,113,336",
+    "method": "Template matching",
+    "threshold": 0.85,
+    "description": "探索大地图主线tab标题锚点(章字)"
+  },
+  {
+    "itemName": "check_play_title",
+    "imageName": "res_check_play_title.png",
+    "roiFront": "1073,214,40,32",
+    "roiBack": "1065,210,190,316",
+    "method": "Template matching",
+    "threshold": 0.85,
+    "description": "探索大地图玩法tab标题锚点(御魂)"
   }
 ]

BIN
tasks/Exploration/res/res_check_main_title.png


BIN
tasks/Exploration/res/res_check_play_title.png