Преглед изворни кода

Merge pull request #795 from runhey/dev

Automated PR 2025.03.27
huangrunheng пре 1 година
родитељ
комит
8a8271a35b
33 измењених фајлова са 340 додато и 283 уклоњено
  1. 3 3
      dev_tools/assets_test.py
  2. BIN
      tasks/ActivityShikigami/as/as_ap_activity.png
  3. BIN
      tasks/ActivityShikigami/as/as_battle.png
  4. BIN
      tasks/ActivityShikigami/as/as_fire.png
  5. BIN
      tasks/ActivityShikigami/as/as_shi.png
  6. 5 5
      tasks/ActivityShikigami/as/image.json
  7. 9 0
      tasks/ActivityShikigami/as/ocr.json
  8. 4 2
      tasks/ActivityShikigami/assets.py
  9. 28 23
      tasks/ActivityShikigami/script_task.py
  10. 19 9
      tasks/BondlingFairyland/assets.py
  11. BIN
      tasks/BondlingFairyland/ball/ball_ball_fire.png
  12. BIN
      tasks/BondlingFairyland/ball/ball_ball_help.png
  13. 4 0
      tasks/BondlingFairyland/battle.py
  14. 3 17
      tasks/BondlingFairyland/general_invite.py
  15. 22 4
      tasks/BondlingFairyland/ocr.json
  16. 189 193
      tasks/BondlingFairyland/script_task.py
  17. BIN
      tasks/BondlingFairyland/stone/buy_add.png
  18. BIN
      tasks/BondlingFairyland/stone/buy_plus.png
  19. BIN
      tasks/BondlingFairyland/stone/buy_sub.png
  20. 6 6
      tasks/BondlingFairyland/stone/click.json
  21. 31 4
      tasks/BondlingFairyland/stone/image.json
  22. BIN
      tasks/BondlingFairyland/stone/stone_stone_enter.png
  23. BIN
      tasks/BondlingFairyland/stone/stone_stone_sure.png
  24. 3 3
      tasks/Component/BaseActivity/config_activity.py
  25. 1 1
      tasks/Component/GeneralBattle/assets.py
  26. 1 1
      tasks/Component/GeneralBattle/gb/image.json
  27. 3 3
      tasks/DemonEncounter/script_task.py
  28. 1 1
      tasks/GameUi/assets.py
  29. BIN
      tasks/GameUi/page/page_check_daily.png
  30. 2 2
      tasks/GameUi/page/page_img_3.json
  31. 2 2
      tasks/RichMan/assets.py
  32. 1 1
      tasks/RichMan/shrine.py
  33. 3 3
      tasks/RichMan/shrine/click.json

+ 3 - 3
dev_tools/assets_test.py

@@ -34,10 +34,10 @@ def detect_ocr(file: str, target: RuleOcr):
 
 
 
 
 # 图片文件路径 可以是相对路径
 # 图片文件路径 可以是相对路径
-IMAGE_FILE = r"C:\Users\Neptine\Desktop\404528170-67ec447a-cc2c-4c62-b253-51e383f6a863.png"
+IMAGE_FILE = r"C:\Users\萌萌哒\Desktop\424368633-6b29ec7d-8f68-4cfc-a52f-c671bb159999.png"
 if __name__ == '__main__':
 if __name__ == '__main__':
-    from tasks.SoulsTidy.script_task import ScriptTask
-    targe = ScriptTask.I_UI_CONFIRM
+    from tasks.RyouToppa.script_task import ScriptTask
+    targe = ScriptTask.I_PREPARE_HIGHLIGHT
     print(detect_image(IMAGE_FILE, targe))
     print(detect_image(IMAGE_FILE, targe))
 
 
     # ocr demo
     # ocr demo

BIN
tasks/ActivityShikigami/as/as_ap_activity.png


BIN
tasks/ActivityShikigami/as/as_battle.png


BIN
tasks/ActivityShikigami/as/as_fire.png


BIN
tasks/ActivityShikigami/as/as_shi.png


+ 5 - 5
tasks/ActivityShikigami/as/image.json

@@ -20,10 +20,10 @@
   {
   {
     "itemName": "battle",
     "itemName": "battle",
     "imageName": "as_battle.png",
     "imageName": "as_battle.png",
-    "roiFront": "375,285,35,135",
-    "roiBack": "300,200,153,315",
+    "roiFront": "199,292,35,135",
+    "roiBack": "144,205,153,315",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "进入爬塔"
     "description": "进入爬塔"
   },
   },
   {
   {
@@ -56,10 +56,10 @@
   {
   {
     "itemName": "fire",
     "itemName": "fire",
     "imageName": "as_fire.png",
     "imageName": "as_fire.png",
-    "roiFront": "1135,581,84,78",
+    "roiFront": "1140,583,84,78",
     "roiBack": "1099,522,150,174",
     "roiBack": "1099,522,150,174",
     "method": "Template matching",
     "method": "Template matching",
-    "threshold": 0.8,
+    "threshold": 0.7,
     "description": "点击战斗"
     "description": "点击战斗"
   },
   },
   {
   {

+ 9 - 0
tasks/ActivityShikigami/as/ocr.json

@@ -25,5 +25,14 @@
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
     "description": "还有多少次购买体力的机会"
     "description": "还有多少次购买体力的机会"
+  },
+  {
+    "itemName": "remain_ap_activity2",
+    "roiFront": "775,26,35,29",
+    "roiBack": "775,26,35,29",
+    "mode": "Digit",
+    "method": "Default",
+    "keyword": "",
+    "description": "活动票数(没有百分比)"
   }
   }
 ]
 ]

+ 4 - 2
tasks/ActivityShikigami/assets.py

@@ -49,7 +49,7 @@ class ActivityShikigamiAssets:
 	# 左上角返回 
 	# 左上角返回 
 	I_BACK_GREEN = RuleImage(roi_front=(23,27,44,44), roi_back=(23,27,44,44), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_back_green.png")
 	I_BACK_GREEN = RuleImage(roi_front=(23,27,44,44), roi_back=(23,27,44,44), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_back_green.png")
 	# 进入爬塔 
 	# 进入爬塔 
-	I_BATTLE = RuleImage(roi_front=(375,285,35,135), roi_back=(300,200,153,315), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
+	I_BATTLE = RuleImage(roi_front=(199,292,35,135), roi_back=(144,205,153,315), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_battle.png")
 	# 归鹿之途 
 	# 归鹿之途 
 	I_DRUM = RuleImage(roi_front=(327,627,145,28), roi_back=(256,462,301,232), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
 	I_DRUM = RuleImage(roi_front=(327,627,145,28), roi_back=(256,462,301,232), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_drum.png")
 	# 上锁图标 
 	# 上锁图标 
@@ -57,7 +57,7 @@ class ActivityShikigamiAssets:
 	# 还未上锁图片 
 	# 还未上锁图片 
 	I_UNLOCK = RuleImage(roi_front=(823,654,28,28), roi_back=(776,610,112,87), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
 	I_UNLOCK = RuleImage(roi_front=(823,654,28,28), roi_back=(776,610,112,87), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_unlock.png")
 	# 点击战斗 
 	# 点击战斗 
-	I_FIRE = RuleImage(roi_front=(1135,581,84,78), roi_back=(1099,522,150,174), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
+	I_FIRE = RuleImage(roi_front=(1140,583,84,78), roi_back=(1099,522,150,174), threshold=0.7, method="Template matching", file="./tasks/ActivityShikigami/as/as_fire.png")
 	# 体力按钮 
 	# 体力按钮 
 	I_AP = RuleImage(roi_front=(1138,668,23,24), roi_back=(1088,638,103,71), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
 	I_AP = RuleImage(roi_front=(1138,668,23,24), roi_back=(1088,638,103,71), threshold=0.8, method="Template matching", file="./tasks/ActivityShikigami/as/as_ap.png")
 	# 活动体力 
 	# 活动体力 
@@ -79,5 +79,7 @@ class ActivityShikigamiAssets:
 	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(713,25,95,30), area=(713,25,95,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
 	O_REMAIN_AP_ACTIVITY = RuleOcr(roi=(713,25,95,30), area=(713,25,95,30), mode="DigitCounter", method="Default", keyword="", name="remain_ap_activity")
 	# 还有多少次购买体力的机会 
 	# 还有多少次购买体力的机会 
 	O_REMAIN_BUY = RuleOcr(roi=(808,531,39,42), area=(808,531,39,42), mode="DigitCounter", method="Default", keyword="", name="remain_buy")
 	O_REMAIN_BUY = RuleOcr(roi=(808,531,39,42), area=(808,531,39,42), mode="DigitCounter", method="Default", keyword="", name="remain_buy")
+	# 活动票数(没有百分比) 
+	O_REMAIN_AP_ACTIVITY2 = RuleOcr(roi=(775,26,35,29), area=(775,26,35,29), mode="Digit", method="Default", keyword="", name="remain_ap_activity2")
 
 
 
 

+ 28 - 23
tasks/ActivityShikigami/script_task.py

@@ -45,33 +45,33 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
         self.ui_get_current_page()
         self.ui_get_current_page()
         self.ui_goto(page_main)
         self.ui_goto(page_main)
 
 
-        self.open_buff()
-        self.soul(is_open=True)
-        self.close_buff()
+        # self.open_buff()
+        # self.soul(is_open=True)
+        # self.close_buff()
 
 
         self.home_main()
         self.home_main()
 
 
         # 选择是游戏的体力还是活动的体力
         # 选择是游戏的体力还是活动的体力
         current_ap = config.general_climb.ap_mode
         current_ap = config.general_climb.ap_mode
-        #self.switch(current_ap)
+        self.switch(current_ap)
 
 
         # 设定是否锁定阵容
         # 设定是否锁定阵容
-        # if config.general_battle.lock_team_enable:
-        #     logger.info("Lock team")
-        #     while 1:
-        #         self.screenshot()
-        #         if self.appear_then_click(self.I_UNLOCK, interval=1):
-        #             continue
-        #         if self.appear(self.I_LOCK):
-        #             break
-        # else:
-        #     logger.info("Unlock team")
-        #     while 1:
-        #         self.screenshot()
-        #         if self.appear_then_click(self.I_LOCK, interval=1):
-        #             continue
-        #         if self.appear(self.I_UNLOCK):
-        #             break
+        if config.general_battle.lock_team_enable:
+            logger.info("Lock team")
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_UNLOCK, interval=1):
+                    continue
+                if self.appear(self.I_LOCK):
+                    break
+        else:
+            logger.info("Unlock team")
+            while 1:
+                self.screenshot()
+                if self.appear_then_click(self.I_LOCK, interval=1):
+                    continue
+                if self.appear(self.I_UNLOCK):
+                    break
 
 
         # 流程应该是 在页面处:
         # 流程应该是 在页面处:
         # 1. 判定计数是否超了,时间是否超了
         # 1. 判定计数是否超了,时间是否超了
@@ -176,11 +176,16 @@ class ScriptTask(GameUi, BaseActivity, SwitchSoul, ActivityShikigamiAssets):
         """
         """
         self.screenshot()
         self.screenshot()
         if current_ap == ApMode.AP_ACTIVITY:
         if current_ap == ApMode.AP_ACTIVITY:
-            cu, res, total = self.O_REMAIN_AP_ACTIVITY.ocr(image=self.device.image)
-            if cu == 0 and cu + res == total:
-                logger.warning("Activity ap not enough")
+            res: int = self.O_REMAIN_AP_ACTIVITY2.ocr_digit(self.device.image)
+            if res <= 0:
+                logger.warning(f'Activity ap {res} not enough')
                 return False
                 return False
             return True
             return True
+            # cu, res, total = self.O_REMAIN_AP_ACTIVITY.ocr(image=self.device.image)
+            # if cu == 0 and cu + res == total:
+            #     logger.warning("Activity ap not enough")
+            #     return False
+            # return True
 
 
         elif current_ap == ApMode.AP_GAME:
         elif current_ap == ApMode.AP_GAME:
             cu, res, total = self.O_REMAIN_AP.ocr(image=self.device.image)
             cu, res, total = self.O_REMAIN_AP.ocr(image=self.device.image)

+ 19 - 9
tasks/BondlingFairyland/assets.py

@@ -28,14 +28,18 @@ class BondlingFairylandAssets:
 	# Ocr Rule Assets
 	# Ocr Rule Assets
 	# Ocr-description 
 	# Ocr-description 
 	O_B_BONDLING_CLASS = RuleOcr(roi=(266,271,79,112), area=(287,271,36,112), mode="Single", method="Default", keyword="", name="b_bondling_class")
 	O_B_BONDLING_CLASS = RuleOcr(roi=(266,271,79,112), area=(287,271,36,112), mode="Single", method="Default", keyword="", name="b_bondling_class")
-	# Ocr-description 
+	# 小盘子 
 	O_B_LOW_NUMBER = RuleOcr(roi=(490,24,98,36), area=(490,24,98,36), mode="DigitCounter", method="Default", keyword="", name="b_low_number")
 	O_B_LOW_NUMBER = RuleOcr(roi=(490,24,98,36), area=(490,24,98,36), mode="DigitCounter", method="Default", keyword="", name="b_low_number")
-	# Ocr-description 
+	# 中盘子 
 	O_B_MEDIUM_NUMBER = RuleOcr(roi=(687,21,101,36), area=(687,21,101,36), mode="DigitCounter", method="Default", keyword="", name="b_medium_number")
 	O_B_MEDIUM_NUMBER = RuleOcr(roi=(687,21,101,36), area=(687,21,101,36), mode="DigitCounter", method="Default", keyword="", name="b_medium_number")
-	# Ocr-description 
+	# 大盘子 
 	O_B_HIGH_NUMBER = RuleOcr(roi=(883,23,100,32), area=(883,23,100,32), mode="DigitCounter", method="Default", keyword="", name="b_high_number")
 	O_B_HIGH_NUMBER = RuleOcr(roi=(883,23,100,32), area=(883,23,100,32), mode="DigitCounter", method="Default", keyword="", name="b_high_number")
-	# Ocr-description 
+	# 鸣契石 
 	O_B_STONE_NUMBER = RuleOcr(roi=(858,22,82,40), area=(858,22,82,40), mode="DigitCounter", method="Default", keyword="", name="b_stone_number")
 	O_B_STONE_NUMBER = RuleOcr(roi=(858,22,82,40), area=(858,22,82,40), mode="DigitCounter", method="Default", keyword="", name="b_stone_number")
+	# 召唤契灵数量 
+	O_B_SUMMON_BALL_NUMBER = RuleOcr(roi=(546,540,100,45), area=(546,540,100,45), mode="Single", method="Default", keyword="", name="b_summon_ball_number")
+	# 抓捕契灵剩余数量 
+	O_B_BALL_NUMBER = RuleOcr(roi=(1190,532,70,30), area=(1190,532,70,30), mode="DigitCounter", method="Default", keyword="", name="b_ball_number")
 	# 好友邀请 
 	# 好友邀请 
 	O_FRIEND = RuleOcr(roi=(357,89,100,54), area=(357,89,100,54), mode="Single", method="Default", keyword="", name="friend")
 	O_FRIEND = RuleOcr(roi=(357,89,100,54), area=(357,89,100,54), mode="Single", method="Default", keyword="", name="friend")
 	# 跨区邀请 
 	# 跨区邀请 
@@ -137,17 +141,23 @@ class BondlingFairylandAssets:
 	# description 
 	# description 
 	C_LEFT_1 = RuleClick(roi_front=(167,198,128,265), roi_back=(167,198,128,265), name="left_1")
 	C_LEFT_1 = RuleClick(roi_front=(167,198,128,265), roi_back=(167,198,128,265), name="left_1")
 	# description 
 	# description 
-	C_LEFT_2 = RuleClick(roi_front=(423,190,139,277), roi_back=(423,190,139,277), name="left_2")
+	C_LEFT_2 = RuleClick(roi_front=(423,226,111,241), roi_back=(423,226,111,241), name="left_2")
 	# description 
 	# description 
-	C_LEFT_3 = RuleClick(roi_front=(676,176,159,307), roi_back=(676,176,159,307), name="left_3")
+	C_LEFT_3 = RuleClick(roi_front=(676,176,107,275), roi_back=(676,176,107,275), name="left_3")
 	# description 
 	# description 
-	C_LEFT_4 = RuleClick(roi_front=(923,198,155,279), roi_back=(923,198,155,279), name="left_4")
+	C_LEFT_4 = RuleClick(roi_front=(918,223,108,235), roi_back=(918,223,108,235), name="left_4")
 
 
 
 
 	# Image Rule Assets
 	# Image Rule Assets
 	# description 
 	# description 
-	I_STONE_ENTER = RuleImage(roi_front=(1167,472,38,41), roi_back=(1167,472,38,41), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/stone/stone_stone_enter.png")
+	I_STONE_ENTER = RuleImage(roi_front=(1172,444,38,41), roi_back=(1172,444,38,41), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/stone/stone_stone_enter.png")
+	# description 
+	I_STONE_SURE = RuleImage(roi_front=(644,621,56,39), roi_back=(618,614,120,52), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/stone/stone_stone_sure.png")
+	# description 
+	I_BUY_PLUS = RuleImage(roi_front=(765,543,43,40), roi_back=(765,543,43,40), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/stone/buy_plus.png")
+	# description 
+	I_BUY_ADD = RuleImage(roi_front=(678,540,43,40), roi_back=(678,540,43,40), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/stone/buy_add.png")
 	# description 
 	# description 
-	I_STONE_SURE = RuleImage(roi_front=(1152,601,75,70), roi_back=(1152,601,75,70), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/stone/stone_stone_sure.png")
+	I_BUY_SUB = RuleImage(roi_front=(468,540,43,40), roi_back=(468,540,43,40), threshold=0.8, method="Template matching", file="./tasks/BondlingFairyland/stone/buy_sub.png")
 
 
 
 

BIN
tasks/BondlingFairyland/ball/ball_ball_fire.png


BIN
tasks/BondlingFairyland/ball/ball_ball_help.png


+ 4 - 0
tasks/BondlingFairyland/battle.py

@@ -67,6 +67,8 @@ class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
             # 如果领奖励
             # 如果领奖励
             if self.appear(self.I_REWARD, threshold=0.6):
             if self.appear(self.I_REWARD, threshold=0.6):
                 break
                 break
+            if self.appear(self.I_WIN, threshold=0.6):
+                break
             # 如果开启战斗过程随机滑动
             # 如果开启战斗过程随机滑动
             if random_click_swipt_enable:
             if random_click_swipt_enable:
                 self.random_click_swipt()
                 self.random_click_swipt()
@@ -82,6 +84,8 @@ class BondlingBattle(GeneralBattle, BondlingFairylandAssets):
             action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
             action_click = random.choice([self.C_REWARD_1, self.C_REWARD_2, self.C_REWARD_3])
             if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
             if self.appear_then_click(self.I_REWARD, action=action_click, interval=1.5):
                 continue
                 continue
+            if self.appear_then_click(self.I_WIN, threshold=0.6):
+                break
             if not self.appear(self.I_REWARD):
             if not self.appear(self.I_REWARD):
                 break
                 break
         logger.info("Get reward")
         logger.info("Get reward")

+ 3 - 17
tasks/BondlingFairyland/general_invite.py

@@ -39,7 +39,6 @@ class RoomType(str, Enum):
 class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
 class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
     timer_invite = None
     timer_invite = None
     timer_wait = None
     timer_wait = None
-    timer_emoji = None  # 等待期间如果没有操作的话,可能会导致长时间无响应报错
 
 
     """
     """
 
 
@@ -67,8 +66,6 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
         else:
         else:
             self.timer_invite = Timer(30)
             self.timer_invite = Timer(30)
             self.timer_invite.start()
             self.timer_invite.start()
-            self.timer_emoji = Timer(20)
-            self.timer_emoji.start()
         wait_second = config.wait_time.second + config.wait_time.minute * 60
         wait_second = config.wait_time.second + config.wait_time.minute * 60
         self.timer_wait = Timer(wait_second)
         self.timer_wait = Timer(wait_second)
         self.timer_wait.start()
         self.timer_wait.start()
@@ -84,11 +81,6 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
             if not self.is_in_room():
             if not self.is_in_room():
                 continue
                 continue
 
 
-            if self.timer_emoji and self.timer_emoji.reached():
-                self.timer_emoji.reset()
-                self.appear_then_click(self.I_GI_EMOJI_1)
-                self.appear_then_click(self.I_GI_EMOJI_2)
-
             fire = False  # 是否开启挑战
             fire = False  # 是否开启挑战
             # 如果这个房间最多只容纳两个人(意思是只可以邀请一个人),且已经邀请一个人了,那就开启挑战
             # 如果这个房间最多只容纳两个人(意思是只可以邀请一个人),且已经邀请一个人了,那就开启挑战
             if self.room_type == RoomType.NORMAL_2 and not self.appear(self.I_ADD_1):
             if self.room_type == RoomType.NORMAL_2 and not self.appear(self.I_ADD_1):
@@ -132,7 +124,7 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
                     self.timer_invite.reset()
                     self.timer_invite.reset()
                 else:
                 else:
                     logger.info('Wait for 30s and invite again')
                     logger.info('Wait for 30s and invite again')
-                    self.timer_invite = None
+                    self.timer_invite.reset()
                 self.invite_friends(config)
                 self.invite_friends(config)
 
 
     def ensure_enter(self) -> bool:
     def ensure_enter(self) -> bool:
@@ -510,7 +502,7 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
         :param default_invite:
         :param default_invite:
         :return:
         :return:
         """
         """
-        if not self.appear(self.I_GI_SURE):
+        if not self.appear(self.I_GI_SURE, interval=1.5):
             return False
             return False
 
 
         if default_invite:
         if default_invite:
@@ -566,8 +558,6 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
         :return: 如果成功进入战斗(反正就是不在房间 )返回 True
         :return: 如果成功进入战斗(反正就是不在房间 )返回 True
                  如果失败了,(退出房间)返回 False
                  如果失败了,(退出房间)返回 False
         """
         """
-        self.timer_emoji = Timer(15)
-        self.timer_emoji.start()
         wait_second = wait_time.second + wait_time.minute * 60
         wait_second = wait_time.second + wait_time.minute * 60
         self.timer_wait = Timer(wait_second)
         self.timer_wait = Timer(wait_second)
         self.timer_wait.start()
         self.timer_wait.start()
@@ -596,14 +586,10 @@ class GeneralInvite(BaseTask, BondlingFairylandAssets, GeneralInviteAssets):
 
 
             # 判断是否进入战斗
             # 判断是否进入战斗
             if self.is_in_room(is_screenshot=False):
             if self.is_in_room(is_screenshot=False):
-                if self.timer_emoji.reached():
-                    self.timer_emoji.reset()
-                    self.appear_then_click(self.I_GI_EMOJI_1)
-                    self.appear_then_click(self.I_GI_EMOJI_2)
+                pass
             else:
             else:
                 break
                 break
 
 
-
         # 调出循环只有这些可能性:
         # 调出循环只有这些可能性:
         # 1. 进入战斗(ui是战斗)
         # 1. 进入战斗(ui是战斗)
         # 2. 队长跑路(自己还是在房间里面)
         # 2. 队长跑路(自己还是在房间里面)

+ 22 - 4
tasks/BondlingFairyland/ocr.json

@@ -15,7 +15,7 @@
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
-    "description": "Ocr-description"
+    "description": "小盘子"
   },
   },
   {
   {
     "itemName": "b_medium_number",
     "itemName": "b_medium_number",
@@ -24,7 +24,7 @@
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
-    "description": "Ocr-description"
+    "description": "中盘子"
   },
   },
   {
   {
     "itemName": "b_high_number",
     "itemName": "b_high_number",
@@ -33,7 +33,7 @@
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
-    "description": "Ocr-description"
+    "description": "大盘子"
   },
   },
   {
   {
     "itemName": "b_stone_number",
     "itemName": "b_stone_number",
@@ -42,7 +42,25 @@
     "mode": "DigitCounter",
     "mode": "DigitCounter",
     "method": "Default",
     "method": "Default",
     "keyword": "",
     "keyword": "",
-    "description": "Ocr-description"
+    "description": "鸣契石"
+  },
+  {
+    "itemName": "b_summon_ball_number",
+    "roiFront": "546,540,100,45",
+    "roiBack": "546,540,100,45",
+    "mode": "Single",
+    "method": "Default",
+    "keyword": "",
+    "description": "召唤契灵数量"
+  },
+  {
+    "itemName": "b_ball_number",
+    "roiFront": "1190,532,70,30",
+    "roiBack": "1190,532,70,30",
+    "mode": "DigitCounter",
+    "method": "Default",
+    "keyword": "",
+    "description": "抓捕契灵剩余数量"
   },
   },
   {
   {
     "itemName": "friend",
     "itemName": "friend",

+ 189 - 193
tasks/BondlingFairyland/script_task.py

@@ -35,10 +35,13 @@ class BondlingNumberMax(Exception):
     pass
     pass
 
 
 
 
+""" 契灵 """
+
+
 class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
 class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul, BondlingFairylandAssets):
     ball_pos_list = [None, None, None, None, None]  # 用于记录每一个位置的球是否出现
     ball_pos_list = [None, None, None, None, None]  # 用于记录每一个位置的球是否出现
     first_catch = True  # 用于记录是否是第一次捕捉
     first_catch = True  # 用于记录是否是第一次捕捉
-
+    current_ball_index = 5
     def run(self):
     def run(self):
         # 引用配置
         # 引用配置
         cong = self.config.bondling_fairyland
         cong = self.config.bondling_fairyland
@@ -71,10 +74,10 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         self.limit_count: int = limit_count
         self.limit_count: int = limit_count
 
 
         if UserStatus.handoff1 == cong.bondling_config.user_status:
         if UserStatus.handoff1 == cong.bondling_config.user_status:
-            self.limit_count: int = limit_count//2
+            self.limit_count: int = limit_count // 2
             self.switch_ball()
             self.switch_ball()
         if UserStatus.handoff2 == cong.bondling_config.user_status:
         if UserStatus.handoff2 == cong.bondling_config.user_status:
-            self.limit_count: int = limit_count//2
+            self.limit_count: int = limit_count // 2
             self.run_member()
             self.run_member()
             self.current_count = 0
             self.current_count = 0
             self.ui_get_current_page()
             self.ui_get_current_page()
@@ -91,6 +94,110 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             case _:
             case _:
                 logger.error('Unknown user status')
                 logger.error('Unknown user status')
 
 
+    def run_leader(self):
+
+        """
+        点击 求援, 组队模式
+        """
+
+        success = True
+        is_first = True
+        while 1:
+            def create_bond_team():
+                click_count = 0
+                while 1:
+                    self.screenshot()
+                    if self.appear(self.I_GI_IN_ROOM):
+                        return True
+                    if click_count >= 6:
+                        logger.error('Click fire failed')
+                        logger.error(
+                            'You might need to check your bondling number. It most possibly arrived to the max 500')
+                        raise BondlingNumberMax
+                    # 某些活动的时候出现 “选择共鸣的阴阳师”
+                    if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
+                        continue
+                    if self.check_and_invite(True):
+                        continue
+                    if self.appear(self.I_CREATE_TEAM, interval=1):
+                        self.ensure_private()
+                        self.appear_then_click(self.I_CREATE_TEAM, interval=2)
+                        continue
+                    # 求援
+                    if self.appear(self.I_BALL_HELP, interval=1):
+                        cu, res, total = self.O_B_BALL_NUMBER.ocr(self.device.image)
+                        logger.info(f'ball is cu {cu}, total {total}')
+                        if cu <= 0 and total == 99:
+                            logger.info('ball is not enough')
+                            return False
+                        if self.appear_then_click(self.I_BALL_HELP, interval=2):
+                            sleep(1)
+                            click_count += 1
+                            continue
+
+            self.screenshot()
+
+            if success:
+                is_first = True
+                if not create_bond_team():
+                    return True
+
+            self.check_and_invite(True)
+
+            if self.current_count >= self.limit_count:
+                if self.appear(self.I_GI_IN_ROOM):
+                    # 次数达到也要邀请好友进房间,然后退出,不然队员无法判断是否完成契灵,出现异常
+                    self.run_invite(config=self.config.bondling_fairyland.invite_config, is_over=False)
+                    # 等待三秒让队员进房间,避免队员没进房间出现异常
+                    sleep(3)
+                    logger.info(f'契灵次数:{self.current_count}已完成,退出')
+                    break
+
+            if datetime.now() - self.start_time >= self.limit_time:
+                if self.appear(self.I_GI_IN_ROOM):
+                    logger.info('bondling_fairyland time limit out')
+                    break
+
+            if self.appear(self.I_GI_IN_ROOM):
+                # 点击挑战
+                if not is_first:
+                    if self.run_invite(config=self.config.bondling_fairyland.invite_config):
+                        success = self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
+                    else:
+                        # 邀请失败,退出任务
+                        logger.warning('Invite failed and exit this bondling_fairyland task')
+                        success = False
+                        break
+
+                # 第一次会邀请队友
+                if is_first:
+                    if not self.run_invite(config=self.config.bondling_fairyland.invite_config, is_first=True):
+                        logger.warning('Invite failed and exit this bondling_fairyland task')
+                        success = False
+                        break
+                    else:
+                        is_first = False
+                        success = self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
+                        continue
+        # 当结束或者是失败退出循环的时候只有两个UI的可能,在房间或者是在组队界面
+        # 如果在房间就退出
+        if self.exit_room():
+            pass
+        # 如果在组队界面就退出
+        if self.exit_team():
+            pass
+
+        self.ui_get_current_page()
+        self.ui_goto(page_bondling_fairyland)
+        # 引用配置
+        if UserStatus.handoff1 == self.config.bondling_fairyland.bondling_config.user_status:
+            self.current_count = 0
+            self.run_member()
+        self.ui_get_current_page()
+        self.ui_goto(page_main)
+        self.set_next_run(task='BondlingFairyland', finish=True, success=True)
+        raise TaskEnd
+
     def run_member(self):
     def run_member(self):
         logger.info('Start run member')
         logger.info('Start run member')
         self.ui_get_current_page()
         self.ui_get_current_page()
@@ -141,7 +248,8 @@ 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):
+            if self.appear(self.I_GI_HOME) or self.appear(self.I_GI_EXPLORE) or self.appear(
+                    self.I_CHECK_BONDLING_FAIRYLAND):
                 break
                 break
             # 如果可能在房间就退出
             # 如果可能在房间就退出
             if self.exit_room():
             if self.exit_room():
@@ -156,7 +264,6 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             self.set_next_run(task='BondlingFairyland', finish=True, success=True)
             self.set_next_run(task='BondlingFairyland', finish=True, success=True)
             raise TaskEnd
             raise TaskEnd
 
 
-
     def switch_ball(self):
     def switch_ball(self):
         cong = self.config.bondling_fairyland
         cong = self.config.bondling_fairyland
 
 
@@ -164,41 +271,34 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         bondling_switch_soul = cong.bondling_switch_soul
         bondling_switch_soul = cong.bondling_switch_soul
         battle_config = cong.battle_config
         battle_config = cong.battle_config
 
 
-        current_ball = 0  # 用于记录当前捕捉的球的位置
         success = True
         success = True
         while 1:
         while 1:
 
 
             if not self.in_search_ui(screenshot=True):
             if not self.in_search_ui(screenshot=True):
-                sleep(0.4)
+                self.ui_get_current_page()
+                self.ui_goto(page_bondling_fairyland)
                 continue
                 continue
 
 
-            if current_ball == 0:
-                if self.run_stone(bondling_config.bondling_stone_enable, bondling_config.bondling_stone_class):
-                    current_ball = 5
-                    logger.info(f'Current ball number: {current_ball} ')
-
-                if current_ball == 5:
-                    continue
-                if self.run_search(bondling_config):
-                    current_ball = 5
-                    logger.info(f'Current ball number: {current_ball} ')
-                else:
-                    break
-
             if bondling_config.bondling_mode != BondlingMode.MODE1:
             if bondling_config.bondling_mode != BondlingMode.MODE1:
-                if self.ball_click(current_ball):
-                    pass
+                if self.ball_click(self.current_ball_index):
+                    logger.info(f'Current ball number: {self.current_ball_index} ')
                 else:
                 else:
-                    # 如果点击了四次还是没有进去,那可能说明这个位置没有球
-                    current_ball -= 1
-                    logger.info(f'Current ball number: {current_ball} ')
+                    # 如果点击了3次还是没有进去,那可能说明这个位置没有球
+                    if self.current_ball_index == 1:
+                        if self.run_stone(bondling_config.bondling_stone_enable, bondling_config.bondling_stone_class):
+                            self.current_ball_index = 5
+                            continue
+                        else:
+                            break
+                    else:
+                        self.current_ball_index -= 1
+                    logger.info(f'Current ball number: {self.current_ball_index} ')
                     continue
                     continue
 
 
                 try:
                 try:
                     # 执行捕捉
                     # 执行捕捉
                     if self.run_catch(bondling_config, bondling_switch_soul, battle_config):
                     if self.run_catch(bondling_config, bondling_switch_soul, battle_config):
-                        current_ball -= 1
-                        logger.info(f'Catch successful and current ball number: {current_ball} ')
+                        logger.info(f'Catch successful and current ball number: {self.current_ball_index} ')
                     else:
                     else:
                         break
                         break
                 except BondlingNumberMax:
                 except BondlingNumberMax:
@@ -224,7 +324,6 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         self.set_next_run(task='BondlingFairyland', finish=True, success=True)
         self.set_next_run(task='BondlingFairyland', finish=True, success=True)
         raise TaskEnd
         raise TaskEnd
 
 
-
     def run_stone(self, bondling_stone_enable: bool, bondling_stone_class: BondlingClass):
     def run_stone(self, bondling_stone_enable: bool, bondling_stone_class: BondlingClass):
         """
         """
         使用结契石 进行召唤 契灵
         使用结契石 进行召唤 契灵
@@ -236,7 +335,8 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         """
         """
         if not bondling_stone_enable:
         if not bondling_stone_enable:
             return False
             return False
-
+        self.ui_get_current_page()
+        self.ui_goto(page_bondling_fairyland)
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
             # 检查是不是在探查界面,
             # 检查是不是在探查界面,
@@ -259,10 +359,14 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                     self.wait_until_appear(self.I_STONE_SURE)
                     self.wait_until_appear(self.I_STONE_SURE)
                     action_click = None
                     action_click = None
                     match bondling_stone_class:
                     match bondling_stone_class:
-                        case BondlingClass.LITTLE_KURO: action_click = self.C_LEFT_1
-                        case BondlingClass.SNOWBALL: action_click = self.C_LEFT_2
-                        case BondlingClass.AZURE_BASAN: action_click = self.C_LEFT_3
-                        case BondlingClass.TOMB_GUARD: action_click = self.C_LEFT_4
+                        case BondlingClass.LITTLE_KURO:
+                            action_click = self.C_LEFT_1
+                        case BondlingClass.SNOWBALL:
+                            action_click = self.C_LEFT_2
+                        case BondlingClass.AZURE_BASAN:
+                            action_click = self.C_LEFT_3
+                        case BondlingClass.TOMB_GUARD:
+                            action_click = self.C_LEFT_4
                     sleep(0.5)
                     sleep(0.5)
                     self.click(action_click)
                     self.click(action_click)
 
 
@@ -271,13 +375,28 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                         self.screenshot()
                         self.screenshot()
                         if not self.appear(self.I_STONE_SURE):
                         if not self.appear(self.I_STONE_SURE):
                             break
                             break
+                        for i in range(0, 5):
+                            if self.appear_then_click(self.I_BUY_ADD, interval=1):
+                                sleep(0.5)
+                                continue
+                        if self.appear_then_click(self.I_GI_SURE, interval=1):
+                            continue
+                        # current = self.O_B_SUMMON_BALL_NUMBER.ocr(self.device.image)
+                        # try:
+                        #     if int(current) >= 1:
+                        #         if self.appear_then_click(self.I_STONE_SURE, interval=1):
+                        #             continue
+                        # except ValueError:
+                        #     logger.warning(f'No challenge count, exit')
                         if self.appear_then_click(self.I_STONE_SURE, interval=1):
                         if self.appear_then_click(self.I_STONE_SURE, interval=1):
                             continue
                             continue
+
                     break
                     break
 
 
                 if self.appear_then_click(self.I_STONE_ENTER, interval=1):
                 if self.appear_then_click(self.I_STONE_ENTER, interval=1):
                     click_count += 1
                     click_count += 1
                     continue
                     continue
+            return True
 
 
     def run_search(self, bondling_config: BondlingConfig):
     def run_search(self, bondling_config: BondlingConfig):
         """
         """
@@ -308,8 +427,8 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                 return True
                 return True
 
 
     def run_catch(self, bondling_config: BondlingConfig,
     def run_catch(self, bondling_config: BondlingConfig,
-                        bondling_switch_soul: BondlingSwitchSoul,
-                        battle_config: BattleConfig):
+                  bondling_switch_soul: BondlingSwitchSoul,
+                  battle_config: BattleConfig):
         """
         """
         执行捕捉的(确保进入了结契界面)
         执行捕捉的(确保进入了结契界面)
         :return:
         :return:
@@ -322,12 +441,15 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
         self.lock_team()
         self.lock_team()
         if self.first_catch:
         if self.first_catch:
             self.first_catch = False
             self.first_catch = False
-            self.capture_setting(bondling_config.bondling_mode)
+            # self.capture_setting(bondling_config.bondling_mode)
 
 
         target_plate = None
         target_plate = None
         match bondling_config.bondling_mode:
         match bondling_config.bondling_mode:
-            case BondlingMode.MODE2: target_plate = self.O_B_LOW_NUMBER
-            case BondlingMode.MODE3: target_plate = self.O_B_MEDIUM_NUMBER
+            case BondlingMode.MODE2:
+                target_plate = self.O_B_LOW_NUMBER
+            case BondlingMode.MODE3:
+                target_plate = self.O_B_MEDIUM_NUMBER
+
         def check_plate_number(target_plate):
         def check_plate_number(target_plate):
             self.screenshot()
             self.screenshot()
             cu, res, total = target_plate.ocr(self.device.image)
             cu, res, total = target_plate.ocr(self.device.image)
@@ -336,17 +458,32 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                 return False
                 return False
             return True
             return True
 
 
+        def check_ball_number():
+            self.screenshot()
+            cu, res, total =  self.O_B_BALL_NUMBER.ocr(self.device.image)
+            if cu == 0 and cu + res == total and total == 99:
+                logger.warning(f'No ball number, exit')
+                return False
+            return True
+
         if not check_plate_number(target_plate):
         if not check_plate_number(target_plate):
             return False
             return False
 
 
+        if not check_ball_number():
+            return False
+
         def switch_soul(bondling_class: BondlingClass):
         def switch_soul(bondling_class: BondlingClass):
             # 按照结契的来切换御魂
             # 按照结契的来切换御魂
             group_team: str = None
             group_team: str = None
             match bondling_class:
             match bondling_class:
-                case BondlingClass.AZURE_BASAN: group_team = bondling_switch_soul.azure_basan_switch
-                case BondlingClass.SNOWBALL: group_team = bondling_switch_soul.snowball_switch
-                case BondlingClass.LITTLE_KURO: group_team = bondling_switch_soul.little_kuro_switch
-                case BondlingClass.TOMB_GUARD: group_team = bondling_switch_soul.tomb_guard_switch
+                case BondlingClass.AZURE_BASAN:
+                    group_team = bondling_switch_soul.azure_basan_switch
+                case BondlingClass.SNOWBALL:
+                    group_team = bondling_switch_soul.snowball_switch
+                case BondlingClass.LITTLE_KURO:
+                    group_team = bondling_switch_soul.little_kuro_switch
+                case BondlingClass.TOMB_GUARD:
+                    group_team = bondling_switch_soul.tomb_guard_switch
             group_team = switch_parser(group_team)
             group_team = switch_parser(group_team)
             if group_team == [-1, -1]:
             if group_team == [-1, -1]:
                 logger.info(f'{bondling_class.name} switch soul is not set, skip')
                 logger.info(f'{bondling_class.name} switch soul is not set, skip')
@@ -363,7 +500,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             switch_soul(bondling_class)
             switch_soul(bondling_class)
 
 
         # 开始执行循环
         # 开始执行循环
-        success =True
+        success = True
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
 
 
@@ -387,22 +524,13 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             # 引用配置
             # 引用配置
             cong = self.config.bondling_fairyland
             cong = self.config.bondling_fairyland
             match cong.bondling_config.user_status:
             match cong.bondling_config.user_status:
-                case UserStatus.LEADER:
-                    if self.run_leader():
-                        return success
-                case UserStatus.handoff1:
-                    if self.run_leader():
-                        return success
-                case UserStatus.handoff2:
-                    if self.run_leader():
-                        return success
                 case UserStatus.ALONE:
                 case UserStatus.ALONE:
                     self.run_alone()
                     self.run_alone()
                     if self.run_battle(battle_config, limit_count=self.limit_count):
                     if self.run_battle(battle_config, limit_count=self.limit_count):
                         return success
                         return success
                 case _:
                 case _:
-                    logger.error('Unknown user status')
-
+                    if self.run_leader():
+                        return success
 
 
     def is_room_dead(self) -> bool:
     def is_room_dead(self) -> bool:
         # 如果在探索界面或者是出现在组队界面,那就是可能房间死了
         # 如果在探索界面或者是出现在组队界面,那就是可能房间死了
@@ -453,41 +581,13 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
                 return ball.roi_front
                 return ball.roi_front
         return None
         return None
 
 
-    def ball_number(self) -> int:
-        """
-        !!! 弃用,原因是发现进行探查的时候会出现: 你的阴阳师会挡住球的位置,导致识别不到球
-
-        获取当前球的数量, 探查阶段优化使用的,但是在你抓完契灵后记得清空
-        :return:
-        """
-        self.screenshot()
-        count = 0
-        for index, ball_pos in enumerate(self.ball_pos_list):
-            if ball_pos is not None:
-                count += 1
-                continue
-            appear_roi = self.roi_appear_ball(self.balls_roi[index], self.device.image)
-            if appear_roi is not None:
-                count += 1
-                self.ball_pos_list[index] = appear_roi
-
-        return count
-
-    def use_stone(self, bondling_class: BondlingClass) -> bool:
-        """
-        使用契灵石
-        :param bondling_class:
-        :return: 如果使用成功,那就返回True 如果已经有五个了返回False
-        """
-
-        return False
-
     def ball_click(self, index: int) -> bool:
     def ball_click(self, index: int) -> bool:
         """
         """
         点击球, 进去结契战斗的界面
         点击球, 进去结契战斗的界面
         :param index:
         :param index:
         :return:
         :return:
         """
         """
+
         def get_click_target(ind: int):
         def get_click_target(ind: int):
             if ind > 5 or ind < 1:
             if ind > 5 or ind < 1:
                 raise ValueError('index must be 1-5')
                 raise ValueError('index must be 1-5')
@@ -507,7 +607,7 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_CLICK_CAPTION):
             if self.appear(self.I_CLICK_CAPTION):
                 return True
                 return True
-            if click_count >= 5:
+            if click_count >= 3:
                 return False
                 return False
             # 点击
             # 点击
             if self.click(click_target, interval=1):
             if self.click(click_target, interval=1):
@@ -642,112 +742,6 @@ class ScriptTask(GameUi, GeneralInvite, GeneralRoom, BondlingBattle, SwitchSoul,
             if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
             if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
                 continue
                 continue
 
 
-    def run_leader(self):
-
-        """
-        点击 求援, 组队模式
-        """
-        click_count = 0
-        # target = None
-        # appear1 = self.I_CREATE_ENSURE.match(self.device.image)
-        while 1:
-            self.screenshot()
-            if click_count >= 6:
-                logger.error('Click fire failed')
-                logger.error('You might need to check your bondling number. It most possibly arrived to the max 500')
-                raise BondlingNumberMax
-            if self.appear(self.I_CREATE_TEAM):
-                break
-            # 某些活动的时候出现 “选择共鸣的阴阳师”
-            if self.appear_then_click(self.I_UI_CONFIRM, interval=1):
-                continue
-            # 盘子满了继续
-            if self.check_and_invite(True):
-                continue
-            # 求援
-            if self.appear_then_click(self.I_BALL_HELP, interval=1):
-                click_count += 1
-                continue
-
-        while 1:
-            self.screenshot()
-            if self.ensure_private():
-                break
-        while 1:
-            self.screenshot()
-
-            if self.appear(self.I_GI_IN_ROOM):
-                break
-            if self.appear_then_click(self.I_CREATE_TEAM, interval=1):
-                continue
-
-        # 邀请队友
-        success = True
-        is_first = True
-        # 这个时候我已经进入房间了哦
-        while 1:
-            self.screenshot()
-
-            # 无论胜利与否, 都会出现是否邀请一次队友
-            # 区别在于,失败的话不会出现那个勾选默认邀请的框
-            self.check_and_invite(True)
-
-            if self.current_count >= self.limit_count:
-                if self.appear(self.I_GI_IN_ROOM):
-                    # 次数达到也要邀请好友进房间,然后退出,不然队员无法判断是否完成契灵,出现异常
-                    self.run_invite(config=self.config.bondling_fairyland.invite_config, is_over=False)
-                    # 等待三秒让队员进房间,避免队员没进房间出现异常
-                    sleep(3)
-                    logger.info('bondling_fairyland count limit out')
-                    break
-
-            if datetime.now() - self.start_time >= self.limit_time:
-                if self.appear(self.I_GI_IN_ROOM):
-                    logger.info('bondling_fairyland time limit out')
-                    break
-
-            if self.appear(self.I_GI_IN_ROOM):
-                # 点击挑战
-                if not is_first:
-                    if self.run_invite(config=self.config.bondling_fairyland.invite_config):
-                        self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
-                    else:
-                        # 邀请失败,退出任务
-                        logger.warning('Invite failed and exit this bondling_fairyland task')
-                        success = False
-                        break
-
-                # 第一次会邀请队友
-                if is_first:
-                    if not self.run_invite(config=self.config.bondling_fairyland.invite_config, is_first=True):
-                        logger.warning('Invite failed and exit this bondling_fairyland task')
-                        success = False
-                        break
-                    else:
-                        is_first = False
-                        self.run_battle(self.config.bondling_fairyland.battle_config, limit_count=self.limit_count)
-                        continue
-            if self.appear(self.I_CHECK_BONDLING_FAIRYLAND):
-                return True
-        # 当结束或者是失败退出循环的时候只有两个UI的可能,在房间或者是在组队界面
-        # 如果在房间就退出
-        if self.exit_room():
-            pass
-        # 如果在组队界面就退出
-        if self.exit_team():
-            pass
-
-        self.ui_get_current_page()
-        self.ui_goto(page_bondling_fairyland)
-        # 引用配置
-        if UserStatus.handoff1 == self.config.bondling_fairyland.bondling_config.user_status:
-            self.current_count = 0
-            self.run_member()
-        self.ui_get_current_page()
-        self.ui_goto(page_main)
-        self.set_next_run(task='BondlingFairyland', finish=True, success=True)
-        raise TaskEnd
-
     def wait_battle(self, wait_time: time) -> bool:
     def wait_battle(self, wait_time: time) -> bool:
         """
         """
         在房间等待,(要求保证在房间里面) 队长开启战斗
         在房间等待,(要求保证在房间里面) 队长开启战斗
@@ -766,7 +760,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):
+            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):
                 logger.warning('Room destroyed')
                 logger.warning('Room destroyed')
                 success = False
                 success = False
                 break
                 break
@@ -918,8 +912,10 @@ if __name__ == '__main__':
     config = Config('oas1')
     config = Config('oas1')
     device = Device(config)
     device = Device(config)
     task = ScriptTask(config, device)
     task = ScriptTask(config, device)
-    image = task.screenshot()
+    # image = task.screenshot()
 
 
-    con = config.bondling_fairyland
+    # con = config.bondling_fairyland
     # task.lock_team()
     # task.lock_team()
     task.run()
     task.run()
+    # task.run_stone(True,BondlingClass.TOMB_GUARD)
+    # task.run_invite(config=config.bondling_fairyland.invite_config, is_over=False, is_first=True)

BIN
tasks/BondlingFairyland/stone/buy_add.png


BIN
tasks/BondlingFairyland/stone/buy_plus.png


BIN
tasks/BondlingFairyland/stone/buy_sub.png


+ 6 - 6
tasks/BondlingFairyland/stone/click.json

@@ -7,20 +7,20 @@
   },
   },
   {
   {
     "itemName": "left_2",
     "itemName": "left_2",
-    "roiFront": "423,190,139,277",
-    "roiBack": "423,190,139,277",
+    "roiFront": "423,226,111,241",
+    "roiBack": "423,226,111,241",
     "description": "description"
     "description": "description"
   },
   },
   {
   {
     "itemName": "left_3",
     "itemName": "left_3",
-    "roiFront": "676,176,159,307",
-    "roiBack": "676,176,159,307",
+    "roiFront": "676,176,107,275",
+    "roiBack": "676,176,107,275",
     "description": "description"
     "description": "description"
   },
   },
   {
   {
     "itemName": "left_4",
     "itemName": "left_4",
-    "roiFront": "923,198,155,279",
-    "roiBack": "923,198,155,279",
+    "roiFront": "918,223,108,235",
+    "roiBack": "918,223,108,235",
     "description": "description"
     "description": "description"
   }
   }
 ]
 ]

+ 31 - 4
tasks/BondlingFairyland/stone/image.json

@@ -2,8 +2,8 @@
   {
   {
     "itemName": "stone_enter",
     "itemName": "stone_enter",
     "imageName": "stone_stone_enter.png",
     "imageName": "stone_stone_enter.png",
-    "roiFront": "1167,472,38,41",
-    "roiBack": "1167,472,38,41",
+    "roiFront": "1172,444,38,41",
+    "roiBack": "1172,444,38,41",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"
@@ -11,8 +11,35 @@
   {
   {
     "itemName": "stone_sure",
     "itemName": "stone_sure",
     "imageName": "stone_stone_sure.png",
     "imageName": "stone_stone_sure.png",
-    "roiFront": "1152,601,75,70",
-    "roiBack": "1152,601,75,70",
+    "roiFront": "644,621,56,39",
+    "roiBack": "618,614,120,52",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "buy_plus",
+    "imageName": "buy_plus.png",
+    "roiFront": "765,543,43,40",
+    "roiBack": "765,543,43,40",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "buy_add",
+    "imageName": "buy_add.png",
+    "roiFront": "678,540,43,40",
+    "roiBack": "678,540,43,40",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "description"
+  },
+  {
+    "itemName": "buy_sub",
+    "imageName": "buy_sub.png",
+    "roiFront": "468,540,43,40",
+    "roiBack": "468,540,43,40",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"

BIN
tasks/BondlingFairyland/stone/stone_stone_enter.png


BIN
tasks/BondlingFairyland/stone/stone_stone_sure.png


+ 3 - 3
tasks/Component/BaseActivity/config_activity.py

@@ -65,6 +65,6 @@ class GeneralClimb(ConfigBase):
             return def_value
             return def_value
         return def_value
         return def_value
 
 
-    @field_validator('ap_mode', mode='after')
-    def check_mode(cls, value):
-        return ApMode.AP_GAME
+    # @field_validator('ap_mode', mode='after')
+    # def check_mode(cls, value):
+    #     return ApMode.AP_GAME

+ 1 - 1
tasks/Component/GeneralBattle/assets.py

@@ -72,7 +72,7 @@ class GeneralBattleAssets:
 	# 预设的小图标 
 	# 预设的小图标 
 	I_PRESET = RuleImage(roi_front=(32,650,47,45), roi_back=(32,650,47,45), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_preset.png")
 	I_PRESET = RuleImage(roi_front=(32,650,47,45), roi_back=(32,650,47,45), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_preset.png")
 	# 准备 
 	# 准备 
-	I_PREPARE_HIGHLIGHT = RuleImage(roi_front=(1128,536,100,100), roi_back=(1128,536,100,100), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_prepare_highlight.png")
+	I_PREPARE_HIGHLIGHT = RuleImage(roi_front=(1128,536,100,100), roi_back=(1110,500,169,200), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_prepare_highlight.png")
 	# 战斗胜利 
 	# 战斗胜利 
 	I_WIN = RuleImage(roi_front=(385,47,100,100), roi_back=(296,33,414,224), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_win.png")
 	I_WIN = RuleImage(roi_front=(385,47,100,100), roi_back=(296,33,414,224), threshold=0.8, method="Template matching", file="./tasks/Component/GeneralBattle/gb/gb_win.png")
 	# 准备但是界面还未加载这个时候是黑色的 
 	# 准备但是界面还未加载这个时候是黑色的 

+ 1 - 1
tasks/Component/GeneralBattle/gb/image.json

@@ -21,7 +21,7 @@
     "itemName": "prepare_highlight",
     "itemName": "prepare_highlight",
     "imageName": "gb_prepare_highlight.png",
     "imageName": "gb_prepare_highlight.png",
     "roiFront": "1128,536,100,100",
     "roiFront": "1128,536,100,100",
-    "roiBack": "1128,536,100,100",
+    "roiBack": "1110,500,169,200",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "准备"
     "description": "准备"

+ 3 - 3
tasks/DemonEncounter/script_task.py

@@ -469,9 +469,9 @@ class ScriptTask(GameUi, GeneralBattle, DemonEncounterAssets, SwitchSoul):
             target_time = datetime(now.year, now.month, now.day, 17, 30, 0)
             target_time = datetime(now.year, now.month, now.day, 17, 30, 0)
             self.set_next_run(task='DemonEncounter', success=False, finish=False, target=target_time)
             self.set_next_run(task='DemonEncounter', success=False, finish=False, target=target_time)
             return False
             return False
-        elif now.hour >= 22:
-            # 22点之后,推迟到第二天的17:30
-            logger.info('After 22:00, wait to 17:30')
+        elif now.hour >= 23:
+            # 23点之后,推迟到第二天的17:30
+            logger.info('After 23:00, wait to 17:30')
             target_time = datetime(now.year, now.month, now.day, 17, 30, 0) + timedelta(days=1)
             target_time = datetime(now.year, now.month, now.day, 17, 30, 0) + timedelta(days=1)
             self.set_next_run(task='DemonEncounter', success=False, finish=False, target=target_time)
             self.set_next_run(task='DemonEncounter', success=False, finish=False, target=target_time)
             return False
             return False

+ 1 - 1
tasks/GameUi/assets.py

@@ -151,7 +151,7 @@ class GameUiAssets:
 	# description 
 	# description 
 	I_CHECK_FRIENDS = RuleImage(roi_front=(1011,592,133,60), roi_back=(1011,592,133,60), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_friends.png")
 	I_CHECK_FRIENDS = RuleImage(roi_front=(1011,592,133,60), roi_back=(1011,592,133,60), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_friends.png")
 	# description 
 	# description 
-	I_CHECK_DAILY = RuleImage(roi_front=(27,515,69,62), roi_back=(1,489,155,127), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_daily.png")
+	I_CHECK_DAILY = RuleImage(roi_front=(28,515,58,62), roi_back=(1,487,154,145), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_daily.png")
 	# description 
 	# description 
 	I_CHECK_MALL = RuleImage(roi_front=(147,527,82,82), roi_back=(147,527,82,82), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_mall.png")
 	I_CHECK_MALL = RuleImage(roi_front=(147,527,82,82), roi_back=(147,527,82,82), threshold=0.8, method="Template matching", file="./tasks/GameUi/page/page_check_mall.png")
 	# description 
 	# description 

BIN
tasks/GameUi/page/page_check_daily.png


+ 2 - 2
tasks/GameUi/page/page_img_3.json

@@ -101,8 +101,8 @@
   {
   {
     "itemName": "check_daily",
     "itemName": "check_daily",
     "imageName": "page_check_daily.png",
     "imageName": "page_check_daily.png",
-    "roiFront": "27,515,69,62",
-    "roiBack": "1,489,155,127",
+    "roiFront": "28,515,58,62",
+    "roiBack": "1,487,154,145",
     "method": "Template matching",
     "method": "Template matching",
     "threshold": 0.8,
     "threshold": 0.8,
     "description": "description"
     "description": "description"

+ 2 - 2
tasks/RichMan/assets.py

@@ -304,8 +304,8 @@ class RichManAssets:
 
 
 
 
 	# Click Rule Assets
 	# Click Rule Assets
-	# description 
-	C_C_SHRINE = RuleClick(roi_front=(1167,303,102,164), roi_back=(1167,303,102,164), name="c_shrine")
+	# 进入神龛 
+	C_C_SHRINE = RuleClick(roi_front=(1181,320,88,109), roi_back=(1181,320,88,109), name="c_shrine")
 
 
 
 
 	# Image Rule Assets
 	# Image Rule Assets

+ 1 - 1
tasks/RichMan/shrine.py

@@ -25,7 +25,7 @@ class Shrine(GameUi, RichManAssets):
             self.screenshot()
             self.screenshot()
             if self.appear(self.I_S_NEXT_PERIOD):
             if self.appear(self.I_S_NEXT_PERIOD):
                 break
                 break
-            if self.click(self.C_C_SHRINE, interval=1):
+            if self.click(self.C_C_SHRINE, interval=2):
                 continue
                 continue
             # if self.appear_then_click(self.I_CENTER1, interval=1):
             # if self.appear_then_click(self.I_CENTER1, interval=1):
             #     continue
             #     continue

+ 3 - 3
tasks/RichMan/shrine/click.json

@@ -1,8 +1,8 @@
 [
 [
   {
   {
     "itemName": "c_shrine",
     "itemName": "c_shrine",
-    "roiFront": "1167,303,102,164",
-    "roiBack": "1167,303,102,164",
-    "description": "description"
+    "roiFront": "1181,320,88,109",
+    "roiBack": "1181,320,88,109",
+    "description": "进入神龛"
   }
   }
 ]
 ]