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

Merge remote-tracking branch 'upstream/dev' into develop

Chino dentist Ko 2 лет назад
Родитель
Сommit
3f8400ec9e

+ 5 - 3
tasks/Component/GeneralInvite/general_invite.py

@@ -12,6 +12,7 @@ from module.base.timer import Timer
 from tasks.base_task import BaseTask
 from tasks.base_task import BaseTask
 from tasks.Component.GeneralInvite.assets import GeneralInviteAssets
 from tasks.Component.GeneralInvite.assets import GeneralInviteAssets
 from tasks.Component.GeneralInvite.config_invite import InviteConfig, InviteNumber, FindMode
 from tasks.Component.GeneralInvite.config_invite import InviteConfig, InviteNumber, FindMode
+from tasks.Component.GeneralBattle.assets import GeneralBattleAssets
 from module.logger import logger
 from module.logger import logger
 
 
 
 
@@ -540,9 +541,6 @@ class GeneralInvite(BaseTask, GeneralInviteAssets):
 
 
         return True
         return True
 
 
-
-
-
     def check_then_accept(self) -> bool:
     def check_then_accept(self) -> bool:
         """
         """
         队员接受邀请
         队员接受邀请
@@ -555,6 +553,10 @@ class GeneralInvite(BaseTask, GeneralInviteAssets):
             self.screenshot()
             self.screenshot()
             if self.is_in_room():
             if self.is_in_room():
                 return True
                 return True
+            # 被秒开
+            # https://github.com/runhey/OnmyojiAutoScript/issues/230
+            if self.appear(GeneralBattleAssets.I_EXIT):
+                return False
             if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
             if self.appear_then_click(self.I_I_NO_DEFAULT, interval=1):
                 continue
                 continue
             if self.appear_then_click(self.I_GI_SURE, interval=1):
             if self.appear_then_click(self.I_GI_SURE, interval=1):

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

@@ -96,6 +96,10 @@ class ReplaceShikigami(BaseTask, ReplaceShikigamiAssets):
 
 
             if self.click(click_match, interval=1.5):
             if self.click(click_match, interval=1.5):
                 continue
                 continue
+            if self.click(click_match[6], interval=4.5):
+                # 有的时候第七个格子被占用到寄养上去了
+                # 导致一直无法选上
+                continue
         logger.info('Set shikigami: %d' % shikigami_order)
         logger.info('Set shikigami: %d' % shikigami_order)
 
 
     def detect_no_shikigami(self) -> bool:
     def detect_no_shikigami(self) -> bool:

+ 2 - 1
tasks/Duel/script_task.py

@@ -71,7 +71,7 @@ class ScriptTask(GameUi, GeneralBattle, DuelAssets):
         click_count = 0  # 计数
         click_count = 0  # 计数
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
-            if click_count >= 2:
+            if click_count >= 4:
                 break
                 break
 
 
             if self.appear_then_click(self.I_D_TEAM, interval=1):
             if self.appear_then_click(self.I_D_TEAM, interval=1):
@@ -79,6 +79,7 @@ class ScriptTask(GameUi, GeneralBattle, DuelAssets):
             if self.appear_then_click(self.I_UI_CONFIRM, interval=0.6):
             if self.appear_then_click(self.I_UI_CONFIRM, interval=0.6):
                 continue
                 continue
             if self.appear_then_click(self.I_D_TEAM_SWTICH, interval=1):
             if self.appear_then_click(self.I_D_TEAM_SWTICH, interval=1):
+                click_count += 1
                 continue
                 continue
         logger.info('Souls Switch is complete')
         logger.info('Souls Switch is complete')
         self.ui_click(self.I_UI_BACK_YELLOW, self.I_D_TEAM)
         self.ui_click(self.I_UI_BACK_YELLOW, self.I_D_TEAM)

+ 5 - 1
tasks/Nian/script_task.py

@@ -106,7 +106,11 @@ class ScriptTask(GameUi, GeneralBattle, GeneralRoom, GeneralInvite, NianAssets):
                     self.screenshot()
                     self.screenshot()
                     if not self.appear(self.I_N_WAITING):
                     if not self.appear(self.I_N_WAITING):
                         break
                         break
-                    if self.appear_then_click(self.I_N_WAITING, interval=0.7):
+                    if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                        continue
+                    if self.appear_then_click(self.I_UI_CONFIRM_SAMLL, interval=1):
+                        continue
+                    if self.appear_then_click(self.I_N_WAITING, interval=1):
                         continue
                         continue
                 logger.info('Nian match timeout, exit')
                 logger.info('Nian match timeout, exit')
                 break
                 break

+ 49 - 3
tasks/RealmRaid/script_task.py

@@ -218,6 +218,10 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RealmRaidAssets):
                 else:
                 else:
                     success = False
                     success = False
                     break
                     break
+            # 如果上一轮失败 -> 退出
+            if not last_battle and con.raid_config.when_attack_fail == WhenAttackFail.EXIT:
+                logger.info('Battle lost and exit')
+                break
 
 
 
 
         self.ui_click(self.I_BACK_RED, self.I_CHECK_EXPLORATION)
         self.ui_click(self.I_BACK_RED, self.I_CHECK_EXPLORATION)
@@ -342,7 +346,19 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RealmRaidAssets):
         """
         """
         if screenshot:
         if screenshot:
             self.screenshot()
             self.screenshot()
-        target = self.order_medal.find_anyone(self.device.image)
+        image = self.device.image
+        # https://github.com/runhey/OnmyojiAutoScript/issues/71
+        # 如果开始失败后继挑战剩下的
+        if self.config.realm_raid.raid_config.when_attack_fail == WhenAttackFail.CONTINUE:
+            for i, roi in enumerate(self.false_roi):
+                self.false_image.roi_back = roi
+                if not self.appear(self.false_image):
+                    continue
+                logger.info(f'Position {i+1} is a failed')
+                x, y, w, h = self.partition[i].roi_back
+                image[y:y+h, x:x+w, ...] = 0
+        # -----------------------------------------------------
+        target = self.order_medal.find_anyone(image)
         if target:
         if target:
             center = target.front_center()
             center = target.front_center()
             for i, click in enumerate(self.partition):
             for i, click in enumerate(self.partition):
@@ -465,6 +481,36 @@ class ScriptTask(GeneralBattle, GameUi, SwitchSoul, RealmRaidAssets):
                 continue
                 continue
         logger.info(f'Click fire {order} success')
         logger.info(f'Click fire {order} success')
 
 
+    @cached_property
+    def false_roi(self) -> list:
+        width = 86
+        height = 64
+        x1 = 386
+        x2 = 714
+        x3 = 1047
+        y1 = 143
+        y2 = 277
+        y3 = 414
+        return [
+            [x1, y1, width, height],  # 左上角
+            [x2, y1, width, height],
+            [x3, y1, width, height],
+            [x1, y2, width, height],  # 左中
+            [x2, y2, width, height],
+            [x3, y2, width, height],
+            [x1, y3, width, height],  # 左下
+            [x2, y3, width, height],
+            [x3, y3, width, height],
+        ]
+
+    @cached_property
+    def false_image(self):
+        return RuleImage(roi_front=(0 ,0, 63, 32),
+                         roi_back=(0, 0, 100, 100),
+                         threshold=0.8,
+                         method="Template matching",
+                         file="./tasks/RyouToppa/dev/loser_sign_1.png")
+
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
     from module.config.config import Config
     from module.config.config import Config
@@ -473,8 +519,8 @@ if __name__ == "__main__":
     device = Device(config)
     device = Device(config)
     t = ScriptTask(config, device)
     t = ScriptTask(config, device)
 
 
-    t.run()
+    # t.run()
 
 
-    # print(t.find_one())
+    print(t.find_one())
     # target, order = t.find_one()
     # target, order = t.find_one()
     # print(t.check_medal_is_frog(True, target, order))
     # print(t.check_medal_is_frog(True, target, order))