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

add(BondlingFairyland): cap again and fix check bondling fairyland page

Azure 1 год назад
Родитель
Сommit
3f5b3aaf6a

+ 2 - 0
tasks/BondlingFairyland/assets.py

@@ -111,6 +111,8 @@ class BondlingFairylandAssets:
 	I_BATTLE_FAIL_ABANDON = RuleImage(roi_front=(436,606,115,36), roi_back=(436,606,115,36), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/battle_fail_abandon.png")
 	I_BATTLE_FAIL_ABANDON = RuleImage(roi_front=(436,606,115,36), roi_back=(436,606,115,36), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/battle_fail_abandon.png")
 	# description 
 	# description 
 	I_BATTLE_SUCCESS = RuleImage(roi_front=(651,203,70,81), roi_back=(651,203,70,81), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/battle_success.png")
 	I_BATTLE_SUCCESS = RuleImage(roi_front=(651,203,70,81), roi_back=(651,203,70,81), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/battle_success.png")
+	# 再次结契 
+	I_CAP_AGAIN = RuleImage(roi_front=(730,598,113,53), roi_back=(693,572,176,99), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/capture/capture_cap_again.png")
 
 
 
 
 	# Image Rule Assets
 	# Image Rule Assets

+ 16 - 4
tasks/BondlingFairyland/battle.py

@@ -6,6 +6,7 @@ from datetime import timedelta, datetime
 import random
 import random
 
 
 from module.server.i18n import I18n
 from module.server.i18n import I18n
+from tasks.BondlingFairyland.config import BondlingMode
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.Component.GeneralBattle.general_battle import GeneralBattle
 from tasks.BondlingFairyland.assets import BondlingFairylandAssets
 from tasks.BondlingFairyland.assets import BondlingFairylandAssets
 from tasks.BondlingFairyland.config_battle import BattleConfig
 from tasks.BondlingFairyland.config_battle import BattleConfig
@@ -64,15 +65,28 @@ class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
         # 战斗过程 随机点击和滑动 防封
         # 战斗过程 随机点击和滑动 防封
         logger.info("Start battle process")
         logger.info("Start battle process")
         win: bool = False
         win: bool = False
+        bondling_mode = self.config.bondling_fairyland.bondling_config.bondling_mode
+        cap_again = bondling_mode in [BondlingMode.MODE3, BondlingMode.MODE4]
+        cap_cnt, max_cap = 0, 10
         while 1:
         while 1:
+            # 捕获次数超过最大次数限制, 则不再进行捕获
+            if cap_cnt >= max_cap:
+                cap_again = False
             self.screenshot()
             self.screenshot()
             # 如果捕获成功
             # 如果捕获成功
             if self.appear_then_click(self.I_CAP_SUCCESS, action=self.C_CAP_SUCCESS,  interval=1):
             if self.appear_then_click(self.I_CAP_SUCCESS, action=self.C_CAP_SUCCESS,  interval=1):
                 win = True
                 win = True
-            # 如果捕获失败
+            # 连续结契捕获失败
             if self.appear_then_click(self.I_CAP_FAILURE, action=self.C_CAP_SUCCESS, interval=1):
             if self.appear_then_click(self.I_CAP_FAILURE, action=self.C_CAP_SUCCESS, interval=1):
                 win = False
                 win = False
-
+            # 非连续结契且单次抓捕失败
+            if not cap_again and self.appear_then_click(self.I_BATTLE_FAIL_ABANDON, interval=1):
+                win = False
+            # 连续结契则继续结契
+            if cap_again and self.appear_then_click(self.I_CAP_AGAIN, interval=1):
+                self.device.click_record_clear()  # 需要10次结契因此清空点击记录
+                cap_cnt += 1
+                continue
             # 如果领奖励
             # 如果领奖励
             if self.appear(self.I_REWARD, threshold=0.6):
             if self.appear(self.I_REWARD, threshold=0.6):
                 break
                 break
@@ -80,8 +94,6 @@ class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
                 continue
                 continue
             if self.appear_then_click(self.I_BATTLE_SUCCESS, threshold=0.6, interval=1):
             if self.appear_then_click(self.I_BATTLE_SUCCESS, threshold=0.6, interval=1):
                 continue
                 continue
-            if self.appear_then_click(self.I_BATTLE_FAIL_ABANDON, interval=1):
-                continue
             if self.appear_then_click(self.I_BATTLE_FAIL, threshold=0.6, interval=1):
             if self.appear_then_click(self.I_BATTLE_FAIL, threshold=0.6, interval=1):
                 continue
                 continue
             # 如果开启战斗过程随机滑动
             # 如果开启战斗过程随机滑动

+ 9 - 0
tasks/BondlingFairyland/capture/capture.json

@@ -79,5 +79,14 @@
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
+  },
+  {
+    "itemName": "cap_again",
+    "imageName": "capture_cap_again.png",
+    "roiFront": "730,598,113,53",
+    "roiBack": "693,572,176,99",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "再次结契"
   }
   }
 ]
 ]

BIN
tasks/BondlingFairyland/capture/capture_cap_again.png


+ 3 - 3
tasks/BondlingFairyland/script_task.py

@@ -116,7 +116,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                         self.appear_then_click(self.I_CREATE_TEAM, interval=2)
                         self.appear_then_click(self.I_CREATE_TEAM, interval=2)
                         continue
                         continue
                     # 求援
                     # 求援
-                    if self.appear(self.I_CHECK_BONDLING_FAIRYLAND, interval=1):
+                    if self.appear(self.I_BALL_AREA, interval=1):
                         return False
                         return False
                     if self.appear(self.I_BALL_HELP, interval=1):
                     if self.appear(self.I_BALL_HELP, interval=1):
                         cu, res, total = self.O_B_BALL_NUMBER.ocr(self.device.image)
                         cu, res, total = self.O_B_BALL_NUMBER.ocr(self.device.image)
@@ -240,7 +240,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
 
 
         while 1:
         while 1:
             # 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
             # 有一种情况是本来要退出的,但是队长邀请了进入的战斗的加载界面
-            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND) or self.appear(self.I_BALL_HELP) :
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_BALL_AREA) or self.appear(self.I_BALL_HELP) :
                 break
                 break
             # 如果可能在房间就退出
             # 如果可能在房间就退出
             if self.exit_room():
             if self.exit_room():
@@ -679,7 +679,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             self.screenshot()
             self.screenshot()
 
 
             # 如果自己在探索界面或者是庭院,那就是房间已经被销毁了
             # 如果自己在探索界面或者是庭院,那就是房间已经被销毁了
-            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_CHECK_BONDLING_FAIRYLAND) or self.appear(self.I_BALL_HELP):
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(self.I_BALL_AREA) or self.appear(self.I_BALL_HELP):
                 logger.warning('Room destroyed')
                 logger.warning('Room destroyed')
                 success = False
                 success = False
                 break
                 break