Ver código fonte

Merge remote-tracking branch 'upstream/dev' into feature/sort_module_handman123

XQ 4 meses atrás
pai
commit
aa05d9ebc4

+ 2 - 0
module/device/method/nemu_ipc.py

@@ -214,6 +214,8 @@ class NemuIpcImpl:
             os.path.abspath(os.path.join(nemu_folder, './shell/sdk/external_renderer_ipc.dll')),
             # MuMuPlayer12 5.0
             os.path.abspath(os.path.join(nemu_folder, './nx_device/12.0/shell/sdk/external_renderer_ipc.dll')),
+            # MuMuPlayer15
+            os.path.abspath(os.path.join(nemu_folder, './nx_device/15.0/shell/sdk/external_renderer_ipc.dll')),
         ]
         self.lib = None
         for ipc_dll in list_dll:

+ 51 - 37
tasks/AreaBoss/script_task.py

@@ -147,32 +147,22 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
 
         # 如果已经打过该BOSS,直接跳过不打了
         if self.is_group_ranked():
+            logger.warning("There is no boss could be challenged")
             self.ui_click_until_disappear(self.I_AB_CLOSE_RED, interval=3)
             return True
 
-        if ultra:
-            # 判断是否能切换到极地鬼
-            if not self.get_difficulty():
-                # 如何可以切换,直接切换
-                if self.appear(self.I_AB_DIFFICULTY_NORMAL):
-                    self.switch_difficulty(True)
-                elif self.config.area_boss.boss.Attack_60:
-                    self.switch_to_level_60()
-                    if not self.start_fight():
-                        logger.warning("you are so weakness!")
-                        self.wait_until_appear(self.I_AB_CLOSE_RED)
-                        self.ui_click_until_disappear(self.I_AB_CLOSE_RED, interval=3)
-                        return False
-                else:
-                    self.ui_click_until_disappear(self.I_AB_CLOSE_RED, interval=3)
-                    return False
-                # 切换到 极地鬼
-
-            # 调整悬赏层数
-            match reward_floor:
-                case AreaBossFloor.ONE: self.switch_to_floor_1()
-                case AreaBossFloor.TEN: self.switch_to_floor_10()
-                case AreaBossFloor.DEFAULT: logger.info("Not change floor")
+        # 设置极模式
+        if ultra and self.setup_ultra():
+            pass
+        # 普通模式下的60级
+        elif self.config.area_boss.boss.Attack_60:
+            self.switch_to_level_60()
+            if not self.start_fight():
+                logger.warning("you are so weakness!")
+                self.wait_until_appear(self.I_AB_CLOSE_RED)
+                self.ui_click_until_disappear(self.I_AB_CLOSE_RED, interval=3)
+                return False
+
         result = True
         if not self.start_fight():
             result = False
@@ -190,8 +180,29 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
                 break
 
         return self.run_general_battle(self.config.area_boss.general_battle)
-    
+
+    def setup_ultra(self) -> bool:
+        # 尝试切换
+        if not self.get_difficulty():
+            # 如果可以切换,直接切换
+            if self.appear(self.I_AB_DIFFICULTY_NORMAL):
+                self.switch_difficulty(True)
+            else:
+                logger.warning("Cannot switch difficulty")
+                return False
+        # 调整悬赏层数
+        reward_floor = self.config.area_boss.boss.reward_floor
+        match reward_floor:
+            case AreaBossFloor.ONE:
+                self.switch_to_floor_1()
+            case AreaBossFloor.TEN:
+                self.switch_to_floor_10()
+            case AreaBossFloor.DEFAULT:
+                logger.info("Not change floor")
+        return True
+
     def switch_to_level_60(self):
+        logger.info("Switch to level 60")
         while 1:
             self.screenshot()
             if self.appear(self.I_AB_LEVEL_60):
@@ -199,7 +210,7 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
             if self.appear(self.I_AB_LEVEL_HANDLE):
                 x, y = self.I_AB_LEVEL_HANDLE.front_center()
                 self.S_AB_LEVEL_RIGHT.roi_front = (x, y, 10, 10)
-                self.swipe(self.S_AB_LEVEL_RIGHT)
+                self.swipe(self.S_AB_LEVEL_RIGHT, interval=3)
 
     def get_difficulty(self) -> bool:
         """
@@ -385,18 +396,21 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, AreaBossAssets):
                     False       打开失败
         @rtype:
         """
-        try_num = 3 if try_num <= 0 else try_num
-
-        while try_num > 0:
-            self.click(battle, interval=3)
-            if self.wait_until_appear(self.I_AB_CLOSE_RED, wait_time=3):
-                break
-            try_num -= 1
-        # 打开鬼王详情界面失败,直接返回
-        self.screenshot()
-        if self.appear(self.I_AB_CLOSE_RED):
-            return True
-        return False
+        try_count = 0
+        while 1:
+            self.screenshot()
+            if self.appear(self.I_AB_CLOSE_RED) and self.appear(self.I_FIRE):
+                self.screenshot()
+                if not self.appear(self.I_FIRE):
+                    continue
+                return True
+            if try_count >= try_num:
+                logger.warning(f"Cannot boss_detail, try {try_count} times")
+                return False
+            if self.click(battle, interval=3):
+                try_count += 1
+                continue
+        return True
 
     def is_group_ranked(self):
         """

+ 43 - 20
tasks/BondlingFairyland/general_invite.py

@@ -74,6 +74,11 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
                 logger.warning('Timeout, now is no room')
                 return False
 
+            if self.appear(self.I_INVITE_ENSURE) or self.appear(self.I_GI_CANCEL):
+                logger.warning('Invite page is still open, close it before checking room status')
+                self.close_invite_page()
+                continue
+
             if not self.is_in_room():
                 continue
 
@@ -100,6 +105,25 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
                     self.timer_invite.reset()
                 self.invite_friends(config)
 
+    def close_invite_page(self) -> bool:
+        """
+        Close the invite selector if it is still open, returning to the room page.
+        """
+        logger.info('Close invite page')
+        timer = Timer(3).start()
+        closed = False
+        while not timer.reached():
+            self.screenshot()
+            if not self.appear(self.I_INVITE_ENSURE) and not self.appear(self.I_GI_CANCEL):
+                return closed
+            if self.appear_then_click(self.I_GI_CANCEL, interval=0.8):
+                closed = True
+                continue
+            if self.appear_then_click(self.I_INVITE_ENSURE, interval=0.8):
+                closed = True
+                continue
+        return closed
+
     def ensure_enter(self) -> bool:
         """
         确认是否进入了组队界面
@@ -343,25 +367,26 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
             logger.info('Find recent friend')
             # 获取’最近‘在friend_class中的index
             if '最近' not in friend_class:
-                logger.warning('No recent friend')
-                return False
-            recent_index = friend_class.index('最近')
-            while recent_index == 1:
-                self.screenshot()
-                if self.appear(self.I_FLAG_2_ON):
-                    break
-                if self.appear_then_click(self.I_FLAG_2_OFF, interval=1):
-                    continue
+                logger.warning('No recent friend, fallback to auto find')
+                find_mode = FindMode.AUTO_FIND
+            else:
+                recent_index = friend_class.index('最近')
+                while recent_index == 1:
+                    self.screenshot()
+                    if self.appear(self.I_FLAG_2_ON):
+                        break
+                    if self.appear_then_click(self.I_FLAG_2_OFF, interval=1):
+                        continue
 
-            logger.info(f'Now find friend in ”最近“')
-            sleep(1)
-            if not is_select:
-                if self.detect_select(name):
-                    is_select = True
-            sleep(1)
-            if not is_select:
-                if self.detect_select(name):
-                    is_select = True
+                logger.info(f'Now find friend in “最近”')
+                sleep(1)
+                if not is_select:
+                    if self.detect_select(name):
+                        is_select = True
+                sleep(1)
+                if not is_select:
+                    if self.detect_select(name):
+                        is_select = True
 
         for index in range(len(friend_class)):
             # 如果不是自动寻找,就跳过
@@ -472,5 +497,3 @@ if __name__ == '__main__':
     # t.run_invite(c.orochi.invite_config, is_first=True)
     t.screenshot()
     print(t.appear(t.I_FIRE, threshold=0.8))
-
-

+ 10 - 1
tasks/BondlingFairyland/script_task.py

@@ -113,7 +113,16 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                         continue
                     if self.appear(self.I_CREATE_TEAM, interval=1):
                         self.ensure_private()
-                        self.appear_then_click(self.I_CREATE_TEAM, interval=2)
+                        if self.appear_then_click(self.I_CREATE_TEAM, interval=2):
+                            logger.info('Wait up to 5s for bondling room after creating team')
+                            enter_timer = Timer(5).start()
+                            while not enter_timer.reached():
+                                self.screenshot()
+                                if self.appear(self.I_GI_IN_ROOM) or self.is_in_room(is_screenshot=False):
+                                    logger.info('Bondling room entered after creating team')
+                                    return True
+                                if self.appear(self.I_BALL_HELP) or self.appear(self.I_CREATE_TEAM):
+                                    break
                         continue
                     # 求援
                     if self.appear(self.I_BALL_AREA, interval=1):

+ 2 - 3
tasks/Component/GeneralInvite/assets.py

@@ -84,7 +84,7 @@ class GeneralInviteAssets:
 	# 勾选 默认邀请 
 	I_I_DEFAULT = RuleImage(roi_front=(541,342,41,39), roi_back=(541,342,41,39), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_i_default.png")
 	# description 
-	I_GI_CANCEL = RuleImage(roi_front=(438,407,171,55), roi_back=(438,407,171,55), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_cancel.png")
+	I_GI_CANCEL = RuleImage(roi_front=(438,407,171,55), roi_back=(438,407,171,55), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_cancel.png")
 	# 队长邀请 确定 
 	I_GI_SURE = RuleImage(roi_front=(670,402,175,60), roi_back=(670,402,175,60), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_sure.png")
 	# 所有的组队界面都有加成 
@@ -105,7 +105,7 @@ class GeneralInviteAssets:
 	# 判断是不是在庭院界面 
 	I_GI_HOME = RuleImage(roi_front=(361,34,34,46), roi_back=(361,34,34,46), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_home.png")
 	# 判断是不是在探索界面 
-	I_GI_EXPLORE = RuleImage(roi_front=(677,11,33,46), roi_back=(677,11,33,46), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_explore.png")
+	I_GI_EXPLORE = RuleImage(roi_front=(690,16,28,28), roi_back=(688,8,33,46), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralInvite/gi/gi_gi_explore.png")
 
 
 	# Ocr Rule Assets
@@ -128,4 +128,3 @@ class GeneralInviteAssets:
 	# Ocr-description 
 	O_ONLINE = RuleOcr(roi=(790,102,124,42), area=(0,0,100,100), mode="Single", method="Default", keyword="", name="online")
 
-

BIN
tasks/Component/GeneralInvite/gi/gi_gi_explore.png


+ 2 - 2
tasks/Component/GeneralInvite/gi/image.json

@@ -325,7 +325,7 @@
   },
   {
     "itemName": "gi_cancel",
-    "imageName": "gi_gi_cancel.png",
+    "imageName": "gi_cancel.png",
     "roiFront": "438,407,171,55",
     "roiBack": "438,407,171,55",
     "method": "Template matching",
@@ -377,4 +377,4 @@
     "threshold": 0.8,
     "description": "识别到寄养邀请"
   }
-]
+]

+ 2 - 2
tasks/Component/GeneralInvite/gi/member.json

@@ -29,8 +29,8 @@
   {
     "itemName": "gi_explore",
     "imageName": "gi_gi_explore.png",
-    "roiFront": "677,11,33,46",
-    "roiBack": "677,11,33,46",
+    "roiFront": "690,16,28,28",
+    "roiBack": "688,8,33,46",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "判断是不是在探索界面"

+ 3 - 0
tasks/Component/ReplaceShikigami/replace_shikigami.py

@@ -117,6 +117,9 @@ class ReplaceShikigami(BaseTask, ReplaceShikigamiAssets):
                 clicked = False  # 点击了确认, 恢复选式神的操作
                 continue
 
+            # 是否育成候补式神按钮
+            if self.appear_then_click(self.I_UI_CONFIRM, interval=1) or self.appear_then_click(self.I_UI_CONFIRM_SAMLL, interval=1):
+                continue
             # 与下方点击第7个式神操作互斥, 防止确认按钮还没有出现被下方取消掉
             if not clicked and self.click(click_match, interval=1.5):
                 clicked = True

+ 2 - 2
tasks/GameUi/assets.py

@@ -88,8 +88,8 @@ class GameUiAssets:
 	I_CHECK_AREA_BOSS = RuleImage(roi_front=(20,320,150,130), roi_back=(20,320,150,130), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_area_boss.png")
 	# description 
 	I_CHECK_HEIAN_KITAN = RuleImage(roi_front=(27,48,47,39), roi_back=(27,48,47,39), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_heian_kitan.png")
-	# description 
-	I_CHECK_SIX_GATES = RuleImage(roi_front=(249,33,22,24), roi_back=(227,7,98,85), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_six_gates.png")
+	# 六道之门检查 
+	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_CHECK_BONDLING_FAIRYLAND = RuleImage(roi_front=(614,660,56,49), roi_back=(614,660,56,49), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_bondling_fairyland.png")
 	# description 

BIN
tasks/GameUi/page/page_check_six_gates.png


+ 4 - 4
tasks/GameUi/page/page_img.json

@@ -209,11 +209,11 @@
   {
     "itemName": "check_six_gates",
     "imageName": "page_check_six_gates.png",
-    "roiFront": "249,33,22,24",
-    "roiBack": "227,7,98,85",
+    "roiFront": "411,297,21,21",
+    "roiBack": "395,262,54,85",
     "method": "Template matching",
-    "threshold": 0.8,
-    "description": "description"
+    "threshold": 0.85,
+    "description": "六道之门检查"
   },
   {
     "itemName": "check_bondling_fairyland",

+ 16 - 6
tasks/HeroTest/script_task.py

@@ -3,19 +3,19 @@
 # github https://github.com/runhey
 from datetime import datetime, timedelta, time
 import random  # type: ignore
-from module.atom.image import RuleImage
+from typing import Callable
+
+from module.logger import logger
+from module.exception import TaskEnd
+from module.base.timer import Timer
 
+import tasks.GameUi.page as pages
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.HeroTest.assets import HeroTestAssets
 from tasks.GameUi.game_ui import GameUi
 from tasks.Component.SwitchSoul.switch_soul import SwitchSoul
-
-from module.logger import logger
-from module.exception import TaskEnd
 from tasks.HeroTest.config import Layer, HeroTest, SkillMode
-from typing import Callable
 
-import tasks.GameUi.page as pages
 
 
 class ScriptTask(GameUi, GeneralBattle, HeroTestAssets, SwitchSoul):
@@ -121,8 +121,18 @@ class ScriptTask(GameUi, GeneralBattle, HeroTestAssets, SwitchSoul):
 
     def hero1_skill_wait(self):
         if self.wait_until_appear(self.I_BCMJ_SKILL_ADD_CONFIRM, wait_time=2):
+            timer = Timer(10).start()
             while 1:
                 self.screenshot()
+
+                # https://github.com/runhey/OnmyojiAutoScript/issues/1671
+                if timer.reached_and_reset():
+                    if self.appear(self.I_BCMJ_SKILL_ADD_CONFIRM):
+                        logger.warning('No skill selected for 10s, panel still open, retrying')
+                        continue
+                    logger.warning('Skill selection panel closed unexpectedly, exit')
+                    break
+
                 if self.appear_then_click(self.I_BCMJ_SKILL_ADD1, interval=1):
                     break
                 if self.appear_then_click(self.I_BCMJ_SKILL_ADD2, interval=1):

+ 1 - 1
tasks/RichMan/assets.py

@@ -196,7 +196,7 @@ class RichManAssets:
 	# 荣誉 
 	I_SIDE_CHECK_HONOR = RuleImage(roi_front=(722,11,41,42), roi_back=(722,11,41,42), threshold=0.7, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_side_check_honor.png")
 	# 友情点 
-	I_SIDE_SURE_FRIENDS = RuleImage(roi_front=(1190,287,43,52), roi_back=(1163,258,93,126), threshold=0.7, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_side_sure_friends.png")
+	I_SIDE_SURE_FRIENDS = RuleImage(roi_front=(1190,287,43,52), roi_back=(1159,258,97,296), threshold=0.7, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_side_sure_friends.png")
 	# 友情点 
 	I_SIDE_CHECK_FRIENDS = RuleImage(roi_front=(908,8,39,43), roi_back=(9,8,1266,43), threshold=0.7, method="Template matching", file="./tasks/RichMan/mall/navbar/navbar_side_check_friends.png")
 	# 勋章 

+ 1 - 1
tasks/RichMan/mall/navbar/image_side.json

@@ -39,7 +39,7 @@
     "itemName": "side_sure_friends",
     "imageName": "navbar_side_sure_friends.png",
     "roiFront": "1190,287,43,52",
-    "roiBack": "1163,258,93,126",
+    "roiBack": "1159,258,97,296",
     "method": "Template matching",
     "threshold": 0.7,
     "description": "友情点"