Neptine 1 год назад
Родитель
Сommit
8f0ac741df

+ 9 - 7
tasks/Hyakkiyakou/assets.py

@@ -149,13 +149,13 @@ class HyakkiyakouAssets:
 
 	# Image Rule Assets
 	# description 
-	I_FRIEND_SAME_1 = RuleImage(roi_front=(375,122,106,62), roi_back=(375,122,106,62), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_1.png")
+	I_FRIEND_SAME_1 = RuleImage(roi_front=(349,124,83,50), roi_back=(349,124,83,50), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_1.png")
 	# description 
-	I_FRIEND_REMOTE_1 = RuleImage(roi_front=(498,125,106,56), roi_back=(498,125,106,56), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_1.png")
+	I_FRIEND_REMOTE_1 = RuleImage(roi_front=(444,127,81,46), roi_back=(444,127,81,46), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_1.png")
 	# description 
-	I_FRIEND_SAME_2 = RuleImage(roi_front=(377,126,100,60), roi_back=(377,126,100,60), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_2.png")
+	I_FRIEND_SAME_2 = RuleImage(roi_front=(355,125,80,47), roi_back=(355,125,80,47), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_2.png")
 	# description 
-	I_FRIEND_REMOTE_2 = RuleImage(roi_front=(504,127,100,56), roi_back=(504,127,100,56), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_2.png")
+	I_FRIEND_REMOTE_2 = RuleImage(roi_front=(440,122,89,56), roi_back=(440,122,89,56), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_2.png")
 	# 回归活动使用 
 	I_FRIEND_SAME_1_RECALL = RuleImage(roi_front=(167,123,106,62), roi_back=(154,105,132,94), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_1.png")
 	# 回归活动使用 
@@ -164,10 +164,12 @@ class HyakkiyakouAssets:
 	I_FRIEND_SAME_2_RECALL = RuleImage(roi_front=(168,126,100,60), roi_back=(152,112,133,80), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_same_2.png")
 	# 回归活动使用 
 	I_FRIEND_REMOTE_2_RECALL = RuleImage(roi_front=(296,122,100,56), roi_back=(278,115,131,81), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_remote_2.png")
+	# 寮 
+	I_FRIEND_RYOU_1 = RuleImage(roi_front=(537,126,80,45), roi_back=(537,126,80,45), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_ryou_1.png")
 	# description 
-	I_FRIEND_RYOU_1 = RuleImage(roi_front=(328,128,80,45), roi_back=(328,128,80,45), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_ryou_1.png")
-	# description 
-	I_FRIEND_RYOU_2 = RuleImage(roi_front=(328,128,80,45), roi_back=(328,128,80,45), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_ryou_2.png")
+	I_FRIEND_RYOU_2 = RuleImage(roi_front=(536,127,80,45), roi_back=(536,127,80,45), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_friend_ryou_2.png")
+	# 判断是否进入邀请页面 
+	I_CHECK_INVITATION = RuleImage(roi_front=(629,140,272,57), roi_back=(308,113,826,100), threshold=0.8, method="Template matching", file="./tasks/Hyakkiyakou/hya/hya_check_invitation.png")
 
 
 	# Ocr Rule Assets

BIN
tasks/Hyakkiyakou/hya/hya_friend_remote_1.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_remote_2.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_ryou_1.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_ryou_2.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_same_1.png


BIN
tasks/Hyakkiyakou/hya/hya_friend_same_2.png


+ 22 - 13
tasks/Hyakkiyakou/hya/image5.json

@@ -2,8 +2,8 @@
   {
     "itemName": "friend_same_1",
     "imageName": "hya_friend_same_1.png",
-    "roiFront": "375,122,106,62",
-    "roiBack": "375,122,106,62",
+    "roiFront": "349,124,83,50",
+    "roiBack": "349,124,83,50",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -11,8 +11,8 @@
   {
     "itemName": "friend_remote_1",
     "imageName": "hya_friend_remote_1.png",
-    "roiFront": "498,125,106,56",
-    "roiBack": "498,125,106,56",
+    "roiFront": "444,127,81,46",
+    "roiBack": "444,127,81,46",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -20,8 +20,8 @@
   {
     "itemName": "friend_same_2",
     "imageName": "hya_friend_same_2.png",
-    "roiFront": "377,126,100,60",
-    "roiBack": "377,126,100,60",
+    "roiFront": "355,125,80,47",
+    "roiBack": "355,125,80,47",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -29,8 +29,8 @@
   {
     "itemName": "friend_remote_2",
     "imageName": "hya_friend_remote_2.png",
-    "roiFront": "504,127,100,56",
-    "roiBack": "504,127,100,56",
+    "roiFront": "440,122,89,56",
+    "roiBack": "440,122,89,56",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
@@ -74,19 +74,28 @@
   {
     "itemName": "friend_ryou_1",
     "imageName": "hya_friend_ryou_1.png",
-    "roiFront": "328,128,80,45",
-    "roiBack": "328,128,80,45",
+    "roiFront": "537,126,80,45",
+    "roiBack": "537,126,80,45",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "description"
+    "description": "寮"
   },
   {
     "itemName": "friend_ryou_2",
     "imageName": "hya_friend_ryou_2.png",
-    "roiFront": "328,128,80,45",
-    "roiBack": "328,128,80,45",
+    "roiFront": "536,127,80,45",
+    "roiBack": "536,127,80,45",
     "method": "Template matching",
     "threshold": 0.8,
     "description": "description"
+  },
+  {
+    "itemName": "check_invitation",
+    "imageName": "hya_check_invitation.png",
+    "roiFront": "629,140,272,57",
+    "roiBack": "308,113,826,100",
+    "method": "Template matching",
+    "threshold": 0.8,
+    "description": "判断是否进入邀请页面"
   }
 ]

+ 1 - 1
tasks/Hyakkiyakou/script_task.py

@@ -155,7 +155,7 @@ class ScriptTask(GameUi, HyaSlave):
         if not self.appear(self.I_HACCESS):
             logger.warning('Page Error')
         if self._config.hyakkiyakou_config.hya_invite_friend:
-            self.invite_friend(True)
+            self.invite_friend()
         # start
         self.ui_click(self.I_HACCESS, self.I_HSTART, interval=2)
         self.wait_until_appear(self.I_HTITLE)

+ 41 - 27
tasks/Hyakkiyakou/slave/hya_slave.py

@@ -214,34 +214,48 @@ class HyaSlave(HyaDevice, HyaColor, HyakkiyakouAssets):
     # main process
     # ------------------------------------------------------------------------------------------------------------------
 
-    def invite_friend(self, same: bool = True):
+    def invite_friend(self):
         logger.hr('Invite friend', 2)
-        hya_recall_activity = False
-        while 1:
-            self.screenshot()
-            # 是否有召回活动(星重聚阴阳师)
-            if self.appear(self.I_ENSURE_RECALL):
-                hya_recall_activity = True
-            if hya_recall_activity:
-                if self.appear(self.I_FRIEND_SAME_1_RECALL) or self.appear(self.I_FRIEND_SAME_2_RECALL) or self.appear(self.I_FRIEND_RYOU_1):
-                    break
-            else:
-                if self.appear(self.I_FRIEND_SAME_1) or self.appear(self.I_FRIEND_SAME_2):
-                    break
-            if self.appear_then_click(self.I_HINVITE, interval=4):
-                continue
-        if not self._invite_friend(same=True, hya_recall_activity=hya_recall_activity):
-            if not self._invite_friend(same=False, hya_recall_activity=hya_recall_activity):
-                raise RequestHumanTakeover('Invite friend failed')
-
-    def _invite_friend(self, same: bool = True, hya_recall_activity: bool = False) -> bool:
-        if not same:
-            logger.info('Invite different server friend')
-            # 是否有召回活动
-            if hya_recall_activity:
-                self.ui_click(self.I_FRIEND_REMOTE_1_RECALL, self.I_FRIEND_REMOTE_2_RECALL)
-            else:
-                self.ui_click(self.I_FRIEND_REMOTE_1, self.I_FRIEND_REMOTE_2)
+        self.ui_click(self.I_HINVITE, self.I_CHECK_INVITATION, interval=4)
+        logger.info('Entry check invitation')
+
+        # 是否有召回活动(星重聚阴阳师)
+        if self.appear(self.I_ENSURE_RECALL):
+            hya_recall_activity = True
+            # 应该动态改roi而不是新开一个图
+            friend_buttons1 = [self.I_FRIEND_SAME_1_RECALL, self.I_FRIEND_REMOTE_1_RECALL, ]
+            friend_buttons2 = [self.I_FRIEND_SAME_2_RECALL, self.I_FRIEND_REMOTE_2_RECALL, ]
+        else:
+            hya_recall_activity = False
+            friend_buttons1 = [self.I_FRIEND_SAME_1, self.I_FRIEND_REMOTE_1, self.I_FRIEND_RYOU_1]
+            friend_buttons2 = [self.I_FRIEND_SAME_2, self.I_FRIEND_REMOTE_2, self.I_FRIEND_RYOU_2]
+        # 依次邀请,
+        self.friend_state = 0  # 不需要每一次都从0开始,可以固定一下
+        while self.friend_state < 3:
+            match self.friend_state:
+                case 0:
+                    logger.info('Invite same server friend')
+                    if not self._invite_friend(button1=friend_buttons1[0], button2=friend_buttons2[0], hya_recall_activity=hya_recall_activity):
+                        self.friend_state += 1
+                    else:
+                        return True
+                case 1:
+                    logger.info('Invite remote friend')
+                    if not self._invite_friend(button1=friend_buttons1[1], button2=friend_buttons2[1], hya_recall_activity=hya_recall_activity):
+                        self.friend_state += 1
+                    else:
+                        return True
+                case 2:
+                    logger.info('Invite guild friend')
+                    if not self._invite_friend(button1=friend_buttons1[2], button2=friend_buttons2[2], hya_recall_activity=hya_recall_activity):
+                        self.friend_state += 1
+                    else:
+                        return True
+                case _:
+                    raise RequestHumanTakeover('Invite friend failed')
+
+    def _invite_friend(self, button1: RuleImage, button2: RuleImage, hya_recall_activity: bool = False ) -> bool:
+        self.ui_click(button1, button2)
         invite_timer = Timer(8)
         invite_timer.start()
         while 1: