فهرست منبع

Merge pull request #995 from yEs1do/fix(KekkaiUtilize_FindAP)

修复收取寮体力时可能卡住的 bug
huangrunheng 1 سال پیش
والد
کامیت
9fec782962
4فایلهای تغییر یافته به همراه34 افزوده شده و 9 حذف شده
  1. 9 4
      tasks/KekkaiUtilize/assets.py
  2. 4 4
      tasks/KekkaiUtilize/ku/image.json
  3. 9 0
      tasks/KekkaiUtilize/ku/swipe.json
  4. 12 1
      tasks/KekkaiUtilize/script_task.py

+ 9 - 4
tasks/KekkaiUtilize/assets.py

@@ -19,14 +19,19 @@ class KekkaiUtilizeAssets:
 	I_GUILD_WISH = RuleImage(roi_front=(965,622,60,63), roi_back=(965,622,60,63), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_wish.png")
 	# 神灶 
 	I_GUILD_SHIRNE = RuleImage(roi_front=(872,624,60,62), roi_back=(872,624,60,62), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_shirne.png")
-	# description 
-	I_GUILD_AP = RuleImage(roi_front=(483,314,22,22), roi_back=(225,224,301,167), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_ap.png")
-	# description 
-	I_GUILD_ASSETS = RuleImage(roi_front=(315,311,23,28), roi_back=(227,262,354,136), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_assets.png")
+	# 寮体力 
+	I_GUILD_AP = RuleImage(roi_front=(483,314,22,22), roi_back=(290,224,393,218), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_ap.png")
+	# 寮资金 
+	I_GUILD_ASSETS = RuleImage(roi_front=(315,311,23,28), roi_back=(290,224,393,218), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_assets.png")
 	# 领取寮资金 
 	I_GUILD_ASSETS_RECEIVE = RuleImage(roi_front=(565,426,144,63), roi_back=(565,426,144,63), threshold=0.8, method="Template matching", file="./tasks/KekkaiUtilize/ku/ku_guild_assets_receive.png")
 
 
+	# Swipe Rule Assets
+	# 移动寻找寮体力 
+	S_GUILD_FIND_AP = RuleSwipe(roi_front=(420,546,40,40), roi_back=(8,546,40,40), mode="default", name="guild_find_ap")
+
+
 	# Image Rule Assets
 	# 育成 
 	I_SHI_GROWN = RuleImage(roi_front=(595,291,35,38), roi_back=(530,254,181,198), threshold=0.7, method="Template matching", file="./tasks/KekkaiUtilize/realm/realm_shi_grown.png")

+ 4 - 4
tasks/KekkaiUtilize/ku/image.json

@@ -39,19 +39,19 @@
     "itemName": "guild_ap",
     "imageName": "ku_guild_ap.png",
     "roiFront": "483,314,22,22",
-    "roiBack": "225,224,301,167",
+    "roiBack": "290,224,393,218",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "description"
+    "description": "寮体力"
   },
   {
     "itemName": "guild_assets",
     "imageName": "ku_guild_assets.png",
     "roiFront": "315,311,23,28",
-    "roiBack": "227,262,354,136",
+    "roiBack": "290,224,393,218",
     "method": "Template matching",
     "threshold": 0.8,
-    "description": "description"
+    "description": "寮资金"
   },
   {
     "itemName": "guild_assets_receive",

+ 9 - 0
tasks/KekkaiUtilize/ku/swipe.json

@@ -0,0 +1,9 @@
+[
+  {
+    "itemName": "guild_find_ap",
+    "roiFront": "420,546,40,40",
+    "roiBack": "8,546,40,40",
+    "mode": "default",
+    "description": "移动寻找寮体力"
+  }
+]

+ 12 - 1
tasks/KekkaiUtilize/script_task.py

@@ -76,7 +76,18 @@ class ScriptTask(GameUi, ReplaceShikigami, KekkaiUtilizeAssets):
         :return:
         """
         if ap_enable or assets_enable:
-            self.screenshot()
+            # 尝试移动寻找体力或资金
+            try_find_ap = 0
+            while try_find_ap < 3:
+                self.screenshot()
+                try_find_ap += 1
+                if self.appear(self.I_GUILD_AP) or self.appear(self.I_GUILD_ASSETS):
+                    logger.info('Find ap or assets')
+                    break
+                else:
+                    logger.info('Try find ap or assets')
+                    self.swipe(self.S_GUILD_FIND_AP)
+            # 如果未找到则返回False
             if not self.appear(self.I_GUILD_AP) and not self.appear(self.I_GUILD_ASSETS):
                 logger.info('No ap or assets to collect')
                 return False