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

Merge pull request #1857 from LGG686/dev-f

修复庭院识别错误
huangrunheng 1 месяц назад
Родитель
Сommit
a62a6c9299

+ 16 - 6
tasks/DemonEncounter/assets.py

@@ -60,14 +60,22 @@ class DemonEncounterAssets:
 
 
 	# Click Rule Assets
-	# 从下开始数第一个 
-	C_DE_1 = RuleClick(roi_front=(1211,478,61,58), roi_back=(1211,478,61,58), name="de_1")
+	# 从下开始数第一个(点击区已收缩, 仅包住内部图形)
+	C_DE_1 = RuleClick(roi_front=(1222,497,39,25), roi_back=(1222,497,39,25), name="de_1")
 	# 2 
-	C_DE_2 = RuleClick(roi_front=(1196,409,55,56), roi_back=(1196,409,55,56), name="de_2")
+	C_DE_2 = RuleClick(roi_front=(1204,424,39,31), roi_back=(1204,424,39,31), name="de_2")
 	# 3 
-	C_DE_3 = RuleClick(roi_front=(1225,344,53,55), roi_back=(1225,344,53,55), name="de_3")
+	C_DE_3 = RuleClick(roi_front=(1234,364,32,22), roi_back=(1234,364,32,22), name="de_3")
 	# 第四个 
-	C_DE_4 = RuleClick(roi_front=(1200,282,56,53), roi_back=(1200,282,56,53), name="de_4")
+	C_DE_4 = RuleClick(roi_front=(1214,297,34,27), roi_back=(1214,297,34,27), name="de_4")
+	# 灯笼1类型识别搜索区(须容纳完整灯笼图案, 仅供check_lantern匹配, 不用于点击)
+	C_DE_MATCH_1 = RuleClick(roi_front=(1211,478,61,58), roi_back=(1211,478,61,58), name="de_match_1")
+	# 灯笼2类型识别搜索区
+	C_DE_MATCH_2 = RuleClick(roi_front=(1196,409,55,56), roi_back=(1196,409,55,56), name="de_match_2")
+	# 灯笼3类型识别搜索区
+	C_DE_MATCH_3 = RuleClick(roi_front=(1225,344,53,55), roi_back=(1225,344,53,55), name="de_match_3")
+	# 灯笼4类型识别搜索区
+	C_DE_MATCH_4 = RuleClick(roi_front=(1200,282,56,53), roi_back=(1200,282,56,53), name="de_match_4")
 
 
 	# Image Rule Assets
@@ -96,6 +104,8 @@ class DemonEncounterAssets:
 	I_DE_BALLOON = RuleImage(roi_front=(1214,295,28,27), roi_back=(1198,269,81,266), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_balloon.png")
 	# 右侧的宝箱 
 	I_DE_BOX = RuleImage(roi_front=(1210,295,34,33), roi_back=(1183,278,96,277), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_box.png")
+	# 地图中央未购买的宝箱展示 
+	I_DE_BOX_CENTER = RuleImage(roi_front=(618,325,45,34), roi_back=(547,264,190,157), threshold=0.8, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_box_center.png")
 	# 挑战某一个后的封印图片 
 	I_DE_DEFEAT_2 = RuleImage(roi_front=(1211,422,28,35), roi_back=(1211,422,28,35), threshold=0.7, method="Template matching", file="./tasks/DemonEncounter/demon/demon_de_defeat_2.png")
 	# description 
@@ -126,7 +136,7 @@ class DemonEncounterAssets:
 	# 计数已经开启多少的 
 	O_DE_COUNTER = RuleOcr(roi=(1204,685,48,34), area=(1204,685,48,34), mode="DigitCounter", method="Default", keyword="", name="de_counter")
 	# 现世逢魔顶部今日挑战次数X/1的最小识别区, 0/1表示已打过直接结束 
-	O_DE_CHALLENGE_COUNT = RuleOcr(roi=(705,68,45,36), area=(705,68,45,36), mode="Full", method="Default", keyword="", name="de_challenge_count")
+	O_DE_CHALLENGE_COUNT = RuleOcr(roi=(705,68,45,36), area=(705,68,45,36), mode="DigitCounter", method="Default", keyword="", name="de_challenge_count")
 
 
 	# Click Rule Assets

+ 32 - 8
tasks/DemonEncounter/demon/click.json

@@ -1,26 +1,50 @@
 [
   {
     "itemName": "de_1",
-    "roiFront": "1211,478,61,58",
-    "roiBack": "1211,478,61,58",
+    "roiFront": "1222,497,39,25",
+    "roiBack": "1222,497,39,25",
     "description": "从下开始数第一个"
   },
   {
     "itemName": "de_2",
-    "roiFront": "1196,409,55,56",
-    "roiBack": "1196,409,55,56",
+    "roiFront": "1204,424,39,31",
+    "roiBack": "1204,424,39,31",
     "description": "2"
   },
   {
     "itemName": "de_3",
-    "roiFront": "1225,344,53,55",
-    "roiBack": "1225,344,53,55",
+    "roiFront": "1234,364,32,22",
+    "roiBack": "1234,364,32,22",
     "description": "3"
   },
   {
     "itemName": "de_4",
+    "roiFront": "1214,297,34,27",
+    "roiBack": "1214,297,34,27",
+    "description": "第四个"
+  },
+  {
+    "itemName": "de_match_1",
+    "roiFront": "1211,478,61,58",
+    "roiBack": "1211,478,61,58",
+    "description": "灯笼1类型识别搜索区(须容纳完整灯笼图案, 仅供check_lantern匹配, 不用于点击)"
+  },
+  {
+    "itemName": "de_match_2",
+    "roiFront": "1196,409,55,56",
+    "roiBack": "1196,409,55,56",
+    "description": "灯笼2类型识别搜索区"
+  },
+  {
+    "itemName": "de_match_3",
+    "roiFront": "1225,344,53,55",
+    "roiBack": "1225,344,53,55",
+    "description": "灯笼3类型识别搜索区"
+  },
+  {
+    "itemName": "de_match_4",
     "roiFront": "1200,282,56,53",
     "roiBack": "1200,282,56,53",
-    "description": "第四个"
+    "description": "灯笼4类型识别搜索区"
   }
-]
+]

BIN
tasks/DemonEncounter/demon/demon_de_box_center.png


+ 10 - 1
tasks/DemonEncounter/demon/image.json

@@ -79,5 +79,14 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "50勾玉购买"
+  },
+  {
+    "itemName": "de_box_center",
+    "imageName": "demon_de_box_center.png",
+    "roiFront": "618,325,45,34",
+    "roiBack": "547,264,190,157",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "地图中央未购买的宝箱展示"
   }
-]
+]

+ 1 - 1
tasks/DemonEncounter/demon/ocr.json

@@ -12,7 +12,7 @@
     "itemName": "de_challenge_count",
     "roiFront": "705,68,45,36",
     "roiBack": "705,68,45,36",
-    "mode": "Full",
+    "mode": "DigitCounter",
     "method": "Default",
     "keyword": "",
     "description": "现世逢魔顶部今日挑战次数X/1的最小识别区, 0/1表示已打过直接结束"

+ 85 - 46
tasks/DemonEncounter/script_task.py

@@ -3,7 +3,6 @@
 # github https://github.com/runhey
 import time
 from time import sleep
-import re
 
 from enum import Enum
 from cached_property import cached_property
@@ -61,16 +60,16 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
 
     def check_challenge_done(self) -> bool:
         """
-        OCR识别现世逢魔顶部"今日挑战次数:X/1"
-        :return: True表示0/1今日已打过
+        OCR识别现世逢魔顶部"今日挑战次数:剩余/总", 支持老号X/1与新号X/2
+        DigitCounter 返回 (current, remain, total), current 即剩余次数
+        :return: True表示剩余=0, 今日已打过
         """
-        results = self.O_DE_CHALLENGE_COUNT.detect_and_ocr(self.device.image)
-        text = ''.join(r.ocr_text for r in results)
-        m = re.search(r'([01])\s*/\s*1', text)
-        if not m:
-            logger.warning(f'Challenge count not recognized: [{text}], continue by default')
-            return False
-        return m.group(1) == '0'
+        current, _remain, total = self.O_DE_CHALLENGE_COUNT.ocr(self.device.image)
+        if total > 0:
+            logger.info(f'Demon encounter challenge count: {current}/{total}')
+            return current == 0
+        logger.warning('Challenge count not recognized, assume attempts remain')
+        return False
 
     def checkout_soul(self):
         """
@@ -94,40 +93,77 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
         logger.hr('Start boss battle', 1)
 
         def find_boss():
-            find_btn_clicked = False
-            timer_find_boss = Timer(10 * 60)
-            timer_find_boss.start()
-            while 1:
+            search_button = self.I_DE_BOSS_BEST if self.best_demon_enable else self.I_DE_BOSS
+            boss_name = 'best boss' if self.best_demon_enable else 'normal boss'
+
+            # 每轮搜索前若中央有未购买的宝箱展示, 先点左下角定位(小指针)把它挪开;
+            # 一整轮(2次搜索)都没找到则重进逢魔之时清状态, 最多3轮。
+            for reenter_round in range(1, 4):
                 self.screenshot()
-                if self.appear(self.I_BOSS_FIRE) or self.appear(self.I_BEST_BOSS_FIRE):
-                    break
-                if timer_find_boss.reached():
-                    logger.warning('find boss timeout')
-                    self.set_next_run(task='DemonEncounter', success=False, finish=True, server=False)
-                    raise TaskEnd('DemonEncounter')
-                if self.appear(self.I_JADE_50):
-                    # 没找到boss但地图中央出现宝箱,导致点击宝箱出现50勾玉购买界面
-                    self.ui_click_until_smt_disappear(self.I_DE_FIND, self.I_JADE_50, interval=1)
-                    continue
-                if find_btn_clicked and self.click(self.C_DM_BOSS_CLICK, interval=5):
-                    find_btn_clicked = False
-                    continue
-                if self.best_demon_enable:
+                if self.appear(self.I_DE_BOX_CENTER):
+                    logger.info(
+                        f'Box display at map center, click location to reset view '
+                        f'(round {reenter_round}/3)'
+                    )
+                    self.appear_then_click(self.I_DE_LOCATION, interval=2)
+                    time.sleep(1)
+
+                # 最多重新执行两轮“逢魔/极逢魔 -> 地图中央首领”的完整流程。
+                for search_attempt in range(1, 3):
                     self.device.click_record_clear()
-                    if self.appear(self.I_DE_BOSS_BEST) and (not find_btn_clicked):
-                        self.device.click_record_remove(self.I_DE_BOSS_BEST)
-                        if self.click(self.I_DE_BOSS_BEST, interval=4):
-                            logger.info("Finding best boss...")
-                            find_btn_clicked = True
-                        continue
-                else:
-                    if self.appear(self.I_DE_BOSS) and (not find_btn_clicked):
-                        self.device.click_record_remove(self.I_DE_BOSS)
-                        if self.click(self.I_DE_BOSS, interval=4):
-                            logger.info("Finding normal boss...")
-                            find_btn_clicked = True
+                    self.screenshot()
+                    if self.appear(self.I_BOSS_FIRE) or self.appear(self.I_BEST_BOSS_FIRE):
+                        return True
+                    # 没找到boss但地图中央出现宝箱, 导致点击宝箱出现50勾玉购买界面(事后补救)
+                    if self.appear(self.I_JADE_50):
+                        self.ui_click_until_smt_disappear(self.I_DE_FIND, self.I_JADE_50, interval=1)
                         continue
-            return True
+                    if not self.appear_then_click(search_button, interval=2):
+                        raise GameStuckError(f'Cannot find {boss_name} search button')
+                    logger.info(
+                        f'Finding {boss_name}, attempt {search_attempt}/2 '
+                        f'(re-enter round {reenter_round}/3)...'
+                    )
+                    time.sleep(1)
+
+                    # 每轮点击地图中央框选的红色“集结”区域至多两次,
+                    # 每次等待集结挑战标志5秒。
+                    for center_attempt in range(1, 3):
+                        self.click(self.C_DM_BOSS_CLICK, interval=2)
+                        deadline = time.monotonic() + 5
+                        while time.monotonic() < deadline:
+                            self.screenshot()
+                            if self.appear(self.I_BOSS_FIRE) or self.appear(self.I_BEST_BOSS_FIRE):
+                                logger.info(
+                                    f'{boss_name} gather appeared after center click '
+                                    f'{center_attempt}/2'
+                                )
+                                return True
+                            time.sleep(0.2)
+                        logger.warning(
+                            f'{boss_name} gather did not appear after center click '
+                            f'{center_attempt}/2'
+                        )
+
+                    # 本轮失败,返回逢魔地图,重新点击逢魔/极逢魔进行下一轮搜寻。
+                    self.screenshot()
+                    if self.appear(self.I_UI_BACK_RED):
+                        self.appear_then_click(self.I_UI_BACK_RED, interval=2)
+                        deadline = time.monotonic() + 5
+                        while time.monotonic() < deadline:
+                            self.screenshot()
+                            if self.appear(search_button):
+                                break
+                            time.sleep(0.2)
+
+                # 2次搜索都没找到: 重进地图清状态, 最多3轮
+                logger.info(f'Boss not found, re-enter demon encounter map (round {reenter_round}/3)')
+                self.goto_page(page_demon_encounter)
+                self.goto_page(page_demon_encounter_realworld)
+
+            raise GameStuckError(
+                f'Cannot enter {boss_name} after 3 re-enter rounds'
+            )
 
         def enter_boss():
             logger.info('trying to enter boss...')
@@ -293,11 +329,13 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
         :param index: 四个灯笼,从1开始
         :return:
         """
+        # 分类模板的搜索区(须容纳完整灯笼图案), 与点击区 C_DE_* 分离:
+        # 点击区只包住内部图形, 模板放不进搜索区会全部误判成 battle
         match_roi = {
-            1: self.C_DE_1.roi_front,
-            2: self.C_DE_2.roi_front,
-            3: self.C_DE_3.roi_front,
-            4: self.C_DE_4.roi_front,
+            1: self.C_DE_MATCH_1.roi_front,
+            2: self.C_DE_MATCH_2.roi_front,
+            3: self.C_DE_MATCH_3.roi_front,
+            4: self.C_DE_MATCH_4.roi_front,
         }
         match_empty = {
             1: self.I_DE_DEFEAT_1,
@@ -422,9 +460,10 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
                     break
                 # 如果没有出现红色关闭按钮,说明答题结束
                 if not self.appear(self.I_LETTER_CLOSE):
-                    time.sleep(1.8)
+                    time.sleep(2.5)
                     self.screenshot()
                     if not self.appear(self.I_LETTER_CLOSE):
+                        self.ui_reward_appear_click()
                         logger.warning('Answer finish')
                         return
 

+ 2 - 2
tasks/Dokan/script_task.py

@@ -511,8 +511,8 @@ class ScriptTask(ExtendGreenMark, GameUi, SwitchSoul, DokanSceneDetector):
             if self.appear(self.I_RYOU_DOKAN_DOKAN_QUIT):
                 self.click(self.I_RYOU_DOKAN_DOKAN_QUIT, interval=3)
                 continue
-            if self.appear(self.I_BACK_BL):
-                self.click(self.I_BACK_BL, interval=3)
+            if self.appear(self.I_UI_BACK_BLUE):
+                self.click(self.I_UI_BACK_BLUE, interval=3)
                 continue
             if self.appear(self.I_BACK_Y):
                 self.click(self.I_BACK_Y, interval=3)

+ 4 - 20
tasks/EternitySea/script_task.py

@@ -7,7 +7,7 @@ from module.exception import TaskEnd
 from module.base.timer import Timer
 from module.logger import logger
 
-from tasks.GameUi.game_ui import GameUi, Page
+from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_soul_zones, page_shikigami_records
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralRoom.general_room import GeneralRoom
@@ -44,7 +44,7 @@ class ScriptTask(
             case UserStatus.MEMBER: success = self.run_member()
             case UserStatus.ALONE: success = self.run_alone()
             case _: logger.error('Unknown user status')
-
+        self.goto_page(page_main)
         if success:
             self.set_next_run(self.task_name, finish=True, success=True)
         else:
@@ -55,7 +55,7 @@ class ScriptTask(
 
     def run_leader(self):
         logger.info('Start run leader')
-        self._navigate_to_soul_zones()
+        self.goto_page(page_soul_zones)
         self._enter_eternity_sea()
         layer = self._task_config.eternity_sea_config.layer
         self.check_layer(layer)
@@ -224,7 +224,7 @@ class ScriptTask(
 
     def run_alone(self) -> bool:
         logger.info("Start run alone")
-        self._navigate_to_soul_zones()
+        self.goto_page(page_soul_zones)
         self._enter_eternity_sea()
 
         if self._task_config.general_battle_config.lock_team_enable == False:
@@ -266,16 +266,6 @@ class ScriptTask(
                 return True
         return False
 
-    def eternitysea_enter(self) -> bool:
-        logger.info('Enter EternitySea')
-        while True:
-            self.screenshot()
-            if self.appear(self.I_FORM_TEAM):
-                return True
-            if self.appear_then_click(self.I_ETERNITY_SEA, interval=1):
-                continue
-
-
     def _is_in_eternity_sea(self) -> bool:
         self.screenshot()
         return self.appear(self.I_ETERNITY_SEA_FIRE)
@@ -299,12 +289,6 @@ class ScriptTask(
             if self.appear_then_click(self.I_BACK_BOTTOM, interval=1):
                 continue
 
-    def _navigate_to_soul_zones(self) -> None:
-        self.goto_page(page_soul_zones)
-
-    def _navigate_to_game_page(self, destination: Page) -> None:
-        self.goto_page(destination)
-
     @property
     def _task_config(self) -> EternitySea:
         return self.config.model.eternity_sea

+ 1 - 1
tasks/FallenSun/script_task.py

@@ -284,7 +284,7 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
             self.screenshot()
             if not self.appear(self.I_FORM_TEAM):
                 break
-            if self.appear_then_click(self.I_BACK_BL, interval=2):
+            if self.appear_then_click(self.I_UI_BACK_BLUE, interval=2):
                 continue
             if self.appear_then_click(self.I_UI_BACK_YELLOW, interval=2):
                 continue

+ 17 - 20
tasks/GameUi/assets.py

@@ -10,8 +10,6 @@ from module.atom.list import RuleList
 class GameUiAssets: 
 
 
-
-
 	# Image Rule Assets
 	# description 
 	I_PAPER_DOLL_CLOSE = RuleImage(roi_front=(1253,102,25,62), roi_back=(1238,58,40,153), threshold=0.8, method="Template matching", file="./tasks/GameUi/additional/additional_paper_doll_close.png")
@@ -104,11 +102,13 @@ class GameUiAssets:
 	I_CHECK_MANTRA_TOWER = RuleImage(roi_front=(348,158,30,106), roi_back=(296,117,165,256), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_mantra_tower.png")
 	# 孔雀国标志 
 	I_CHECK_PEACOCK_KINGDOM = RuleImage(roi_front=(348,158,30,106), roi_back=(296,117,165,256), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_peacock_kingdom.png")
+	# 六道之门检查(移植自mine) 
+	I_CHECK_SIX_GATES = RuleImage(roi_front=(411,297,21,21), roi_back=(395,262,54,85), threshold=0.85, method="Template matching", file="./tasks/GameUi/page/page_check_six_gates.png")
 
 
 	# Image Rule Assets
 	# 庭院标志 
-	I_CHECK_MAIN = RuleImage(roi_front=(807,108,76,45), roi_back=(49,98,1033,61), threshold=0.95, method="Template matching", file="./tasks/GameUi/page/page_check_main.png")
+	I_CHECK_MAIN = RuleImage(roi_front=(807,108,76,45), roi_back=(49,98,1033,74), threshold=0.95, method="Template matching", file="./tasks/GameUi/page/page_check_main.png")
 	# 庭院卷轴关闭标识 
 	I_MAIN_SCROLL_CLOSE = RuleImage(roi_front=(1181,634,28,39), roi_back=(1162,595,77,112), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_main_scroll_close.png")
 	# 庭院探索标志 
@@ -163,6 +163,12 @@ class GameUiAssets:
 	I_CHECK_SHRIN = RuleImage(roi_front=(80,92,33,97), roi_back=(56,73,84,138), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_shrin.png")
 	# 阴阳寮前往神社 
 	I_GUILD_TO_SHRIN = RuleImage(roi_front=(877,629,49,53), roi_back=(840,602,302,113), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_guild_to_shrin.png")
+	# 黄色返回按钮 
+	I_BACK_Y = RuleImage(roi_front=(15,4,57,52), roi_back=(1,2,100,91), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_back_y.png")
+	# 黄色返回按钮-大 
+	I_BACK_YOLLOW = RuleImage(roi_front=(24,16,48,55), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_back_yollow.png")
+	# 召唤页返回主页 
+	I_SUMMON_GOTO_MAIN = RuleImage(roi_front=(27,5,49,51), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_summon_goto_main.png")
 
 
 	# Image Rule Assets
@@ -170,10 +176,6 @@ class GameUiAssets:
 	I_CHECK_TOWN = RuleImage(roi_front=(1026,106,68,82), roi_back=(765,98,402,96), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_town.png")
 	# description 
 	I_TOWN_GOTO_MAIN = RuleImage(roi_front=(1017,231,78,73), roi_back=(302,216,868,127), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_town_goto_main.png")
-	# 町中前往娱乐区域
-	I_TOWN_GOTO_ENTERTAINMENT = RuleImage(roi_front=(201,144,35,26), roi_back=(201,144,35,26), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_town_goto_entertainment.png")
-	# 娱乐区域页面标志
-	I_CHECK_ENTERTAINMENT = RuleImage(roi_front=(151,18,102,40), roi_back=(151,18,102,40), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_entertainment.png")
 	# description 
 	I_TOWN_GOTO_DUEL = RuleImage(roi_front=(756,142,48,68), roi_back=(357,126,657,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_town_goto_duel.png")
 	# description 
@@ -198,22 +200,16 @@ class GameUiAssets:
 	I_TOWN_GOTO_HYAKKIYAKOU = RuleImage(roi_front=(880,165,53,69), roi_back=(827,149,148,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_town_goto_hyakkiyakou.png")
 	# 百鬼夜行标志 
 	I_CHECK_KYAKKIYAKOU = RuleImage(roi_front=(1062,564,84,73), roi_back=(68,519,1185,141), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_kyakkiyakou.png")
-	# 逢魔之时新页面标志
+	# 逢魔之时新页面标志 
 	I_CHECK_DEMON_ENCOUNTER_2 = RuleImage(roi_front=(501,441,53,122), roi_back=(358,326,370,288), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_demon_encounter_2.png")
-	# 现世逢魔页面标志
+	# 町中前往娱乐区域 
+	I_TOWN_GOTO_ENTERTAINMENT = RuleImage(roi_front=(201,144,35,26), roi_back=(201,144,35,26), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_town_goto_entertainment.png")
+	# 娱乐区域页面标志 
+	I_CHECK_ENTERTAINMENT = RuleImage(roi_front=(151,18,102,40), roi_back=(151,18,102,40), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_entertainment.png")
+	# 检查逢魔之时现世逢魔界面(移植自mine) 
 	I_CHECK_DEMON_ENCOUNTER_REALWORLD = RuleImage(roi_front=(26,658,42,43), roi_back=(2,619,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_demon_encounter_realworld.png")
-	# 现世逢魔入口
+	# 进入现世逢魔(移植自mine) 
 	I_DEMON_ENCOUNTER_REALWORLD_GOTO = RuleImage(roi_front=(994,485,106,30), roi_back=(994,485,106,30), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_demon_encounter_realworld.png")
-	# description
-	I_BACK_YOLLOW = RuleImage(roi_front=(24,16,48,55), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_back_yollow.png")
-	# description
-	I_BACK_Y = RuleImage(roi_front=(15,4,57,52), roi_back=(1,2,100,91), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_back_y.png")
-	# description
-	I_CHECK_SIX_GATES = RuleImage(roi_front=(411,297,21,21), roi_back=(395,262,54,85), threshold=0.85, method="Template matching", file="./tasks/GameUi/page/page_check_six_gates.png")
-	# description
-	I_SUMMON_GOTO_MAIN = RuleImage(roi_front=(27,5,49,51), roi_back=(0,0,100,100), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_summon_goto_main.png")
-	# description
-	I_BACK_BL = RuleImage(roi_front=(32,31,50,53), roi_back=(1,2,139,120), threshold=0.8, method="Template matching", file="./tasks/GlobalGame/ui/ui_ui_back_blue.png")
 
 
 	# List Rule Assets
@@ -227,3 +223,4 @@ class GameUiAssets:
 	L_ACT_LIST_OCR = RuleList(folder="./tasks/GameUi/page", direction="vertical", mode="ocr", roi_back=(50,123,49,553), size=(45, 69), 
 					 array=["版本"])
 
+

+ 7 - 9
tasks/GameUi/page/image_main.json

@@ -3,7 +3,7 @@
     "itemName": "check_main",
     "imageName": "page_check_main.png",
     "roiFront": "807,108,76,45",
-    "roiBack": "49,98,1033,61",
+    "roiBack": "49,98,1033,74",
     "method": "Template matching",
     "threshold": 0.95,
     "description": "庭院标志"
@@ -258,9 +258,8 @@
     "roiBack": "1,2,100,91",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "黄色返回按钮(移植自mine)"
-  }
-,
+    "description": "黄色返回按钮"
+  },
   {
     "itemName": "back_yollow",
     "imageName": "page_back_yollow.png",
@@ -268,9 +267,8 @@
     "roiBack": "0,0,100,100",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "黄色返回按钮-大(移植自mine)"
-  }
-,
+    "description": "黄色返回按钮-大"
+  },
   {
     "itemName": "summon_goto_main",
     "imageName": "page_summon_goto_main.png",
@@ -278,6 +276,6 @@
     "roiBack": "0,0,100,100",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "召唤页返回主页(移植自mine)"
+    "description": "召唤页返回主页"
   }
-]
+]

+ 8 - 0
tasks/Orochi/assets.py

@@ -25,6 +25,14 @@ class OrochiAssets:
 	I_SHI_RECORDS = RuleImage(roi_front=(842,569,48,45), roi_back=(842,569,48,45), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_shi_records.png")
 	# 小小宠物,发现宝藏 
 	I_PET_PRESENT = RuleImage(roi_front=(873,184,62,147), roi_back=(873,184,62,147), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_pet_present.png")
+	# 八岐大蛇标志 
+	I_OROCHI_CHECK_10 = RuleImage(roi_front=(929,123,203,39), roi_back=(896,100,269,84), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_check_10.png")
+	# 巫女大蛇标志 
+	I_OROCHI_CHECK_11 = RuleImage(roi_front=(929,123,203,39), roi_back=(896,100,269,84), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_check_11.png")
+	# 神罚标志 
+	I_OROCHI_CHECK_12 = RuleImage(roi_front=(929,116,100,46), roi_back=(896,100,269,84), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_check_12.png")
+	# 虚无大蛇标志 
+	I_OROCHI_CHECK_13 = RuleImage(roi_front=(929,121,211,41), roi_back=(896,100,269,84), threshold=0.8, method="Template matching", file="./tasks/Orochi/o/o_orochi_check_13.png")
 
 
 	# List Rule Assets

+ 36 - 0
tasks/Orochi/o/image.json

@@ -61,5 +61,41 @@
     "method": "Template matching",
     "threshold": 0.8,
     "description": "小小宠物,发现宝藏"
+  },
+  {
+    "itemName": "orochi_check_10",
+    "imageName": "o_orochi_check_10.png",
+    "roiFront": "929,123,203,39",
+    "roiBack": "896,100,269,84",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "八岐大蛇标志"
+  },
+  {
+    "itemName": "orochi_check_11",
+    "imageName": "o_orochi_check_11.png",
+    "roiFront": "929,123,203,39",
+    "roiBack": "896,100,269,84",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "巫女大蛇标志"
+  },
+  {
+    "itemName": "orochi_check_12",
+    "imageName": "o_orochi_check_12.png",
+    "roiFront": "929,116,100,46",
+    "roiBack": "896,100,269,84",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "神罚标志"
+  },
+  {
+    "itemName": "orochi_check_13",
+    "imageName": "o_orochi_check_13.png",
+    "roiFront": "929,121,211,41",
+    "roiBack": "896,100,269,84",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "虚无大蛇标志"
   }
 ]

BIN
tasks/Orochi/o/o_orochi_check_10.png


BIN
tasks/Orochi/o/o_orochi_check_11.png


BIN
tasks/Orochi/o/o_orochi_check_12.png


BIN
tasks/Orochi/o/o_orochi_check_13.png


+ 16 - 0
tasks/Orochi/page.py

@@ -0,0 +1,16 @@
+from tasks.GameUi.default_pages import page_exploration, page_soul_zones, page_shikigami_records
+from tasks.GameUi.matcher import any_of
+from tasks.GameUi.page_definition import Page
+from tasks.GlobalGame.assets import GlobalGameAssets
+from tasks.Orochi.assets import OrochiAssets
+
+# 御魂页面(魂1-魂10,魂11,12,13检查标志...)
+page_orochi = Page(any_of(OrochiAssets.I_OROCHI_CHECK_10, OrochiAssets.I_OROCHI_CHECK_11,
+                          OrochiAssets.I_OROCHI_CHECK_12, OrochiAssets.I_OROCHI_CHECK_13))
+page_orochi.connect(page_exploration, GlobalGameAssets.I_UI_BACK_YELLOW, key="page_orochi->page_exploration")
+page_soul_zones.connect(page_orochi, OrochiAssets.I_OROCHI, key="page_soul_zones->page_orochi")
+
+page_orochi.connect(page_shikigami_records, OrochiAssets.I_SHI_RECORDS,
+                    key="page_orochi->page_shikigami_records", cost=2)
+page_shikigami_records.connect(page_orochi, GlobalGameAssets.I_UI_BACK_YELLOW,
+                               key="page_shikigami_records->page_orochi", cost=2)

+ 7 - 19
tasks/Orochi/script_task.py

@@ -13,6 +13,7 @@ from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
 from tasks.GameUi.game_ui import GameUi
 from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
 from tasks.Orochi.assets import OrochiAssets
+from tasks.Orochi.page import page_orochi
 from tasks.Orochi.config import Orochi, UserStatus, Layer
 from tasks.TrueOrochi.assets import TrueOrochiAssets
 from module.logger import logger
@@ -43,8 +44,8 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
         config: Orochi = self.config.orochi
         if not self.is_in_battle(True):
-            self.goto_page(page_main)
             if config.orochi_config.soul_buff_enable:
+                self.goto_page(page_main)
                 self.open_buff()
                 self.soul(is_open=True)
                 self.close_buff()
@@ -59,15 +60,14 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
         # 御魂结束后检测是否出现真蛇
         if config.orochi_config.check_true_orochi_enable:
-            self.goto_page(page_soul_zones)
-            self.orochi_enter()
+            self.goto_page(page_orochi)
             self.screenshot()
             if self.appear(self.I_FIND_TS):
                 logger.info('Find true orochi after orochi battle, set TrueOrochi task to run now')
                 self.set_next_run(task='TrueOrochi', success=False, finish=False, server=False, target=datetime.now())
-        self.goto_page(page_main)
         # 记得关掉
         if config.orochi_config.soul_buff_enable:
+            self.goto_page(page_main)
             self.open_buff()
             self.soul(is_open=False)
             self.close_buff()
@@ -79,14 +79,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
         raise TaskEnd
 
-    def orochi_enter(self) -> bool:
-        logger.info('Enter orochi')
-        while True:
-            self.screenshot()
-            if self.appear(self.I_FORM_TEAM):
-                return True
-            if self.appear_then_click(self.I_OROCHI, interval=1):
-                continue
 
     def check_layer(self, layer: str) -> bool:
         """
@@ -132,8 +124,7 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
     def run_leader(self):
         logger.info('Start run leader')
-        self.goto_page(page_soul_zones)
-        self.orochi_enter()
+        self.goto_page(page_orochi)
         layer = self.config.orochi.orochi_config.layer
         self.check_layer(layer)
         # https://github.com/runhey/OnmyojiAutoScript/issues/592
@@ -224,7 +215,6 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
     def run_member(self):
         logger.info('Start run member')
         # self.ui_goto(page_soul_zones)
-        # self.orochi_enter()
         # self.check_lock(self.config.orochi.general_battle_config.lock_team_enable)
 
         # 进入战斗流程
@@ -273,8 +263,7 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
     def run_alone(self):
         logger.info('Start run alone')
-        self.goto_page(page_soul_zones)
-        self.orochi_enter()
+        self.goto_page(page_orochi)
         layer = self.config.orochi.orochi_config.layer
         self.check_layer(layer)
         self.check_lock(self.config.orochi.general_battle_config.lock_team_enable)
@@ -326,8 +315,7 @@ class ScriptTask(GeneralBattle, GeneralInvite, GeneralBuff, GeneralRoom, GameUi,
 
         # 已经在战斗中不必初始化,保证已经组队开始战斗的情况下可以自动执行后续任务
         if not self.is_in_battle(True):
-            self.goto_page(page_soul_zones)
-            self.orochi_enter()
+            self.goto_page(page_orochi)
             layer = self.config.orochi.orochi_config.layer
             self.check_layer(layer)
             self.check_lock(self.config.orochi.general_battle_config.lock_team_enable)

+ 4 - 5
tasks/TrueOrochi/script_task.py

@@ -14,7 +14,8 @@ from tasks.Component.GeneralInvite.general_invite import GeneralInvite
 from tasks.Component.GeneralRoom.general_room import GeneralRoom
 from tasks.Orochi.script_task import ScriptTask as OrochiScriptTask
 from tasks.Orochi.config import Layer
-from tasks.GameUi.page import page_main, page_soul_zones, page_shikigami_records
+from tasks.Orochi.page import page_orochi
+from tasks.GameUi.page import page_main, page_shikigami_records
 from tasks.TrueOrochi.assets import TrueOrochiAssets
 
 
@@ -40,8 +41,7 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
             self.run_switch_soul_by_name(self.config.true_orochi.switch_soul.group_name,
                                          self.config.true_orochi.switch_soul.team_name)
 
-        self.goto_page(page_soul_zones)
-        self.orochi_enter()
+        self.goto_page(page_orochi)
         sleep(0.5)
         battle = self.check_true_orochi(True)
         if not battle:
@@ -89,8 +89,7 @@ class ScriptTask(OrochiScriptTask, TrueOrochiAssets):
         self.check_times(True)
 
         # 检查是否还有真蛇入口,支持存储两次
-        self.goto_page(page_soul_zones)
-        self.orochi_enter()
+        self.goto_page(page_orochi)
         sleep(0.5)
         if conf.current_success < 2 and self.check_true_orochi(True):
             battle = True