Parcourir la source

!2 fix participate in team

pcacc il y a 2 mois
Parent
commit
1cec948e88

BIN
dongri_img/special_activity/plus_small.png


BIN
dongri_img/special_activity/power_empty.png


+ 2 - 0
dongri_pic.py

@@ -321,6 +321,8 @@ class special_activity_img:
     # participate
     orc_power = (424,148,502,170)
     power0 = R'dongri_img\special_activity\power0.png'
+    power_empty = R'dongri_img\special_activity\power_empty.png'
+    plus_small = R'dongri_img\special_activity\plus_small.png'
     
 def change_direction(direction):
     if len(direction) == 4:

+ 13 - 15
dongri_task.py

@@ -1031,6 +1031,7 @@ class task_paticipateInTeam(dongri_task):
             self.line = monster_img.line4
         super().__init__(f"参与队伍{type}")
     def run(self):
+        
         basic_operate.go_outside()
         if waitClickImg_noWait_withBool(check_img.conflits, 2, 1) == False:
             return False
@@ -1039,31 +1040,28 @@ class task_paticipateInTeam(dongri_task):
             myTimeSleep_big()
             if waitClickImg_noWait_withBool(monster_img.participate, 1, 1, True) == False:
                 return False
-            
+        
         waitClickImg_noWait_withBool(self.line, 0.1, 1)
-
         maxTryTimes = 3
         while maxTryTimes > 0:
             maxTryTimes -= 1
-            if waitFindImg_withBool(special_activity_img.power0, 1, 0) == False:# 实力不为0
-                countStr = yys_ocrAuto(special_activity_img.orc_power)
-                count = 0
-                if len(countStr) == 0:
-                    count = 0
+            if waitFindImg_withBool(special_activity_img.power0, 1, 0.5) == False:# 实力不为0
+                ret1, powerPos = pcacc_img.find_img_origin(special_activity_img.power_empty)
+                ret2, plusPos = pcacc_img.find_img_origin(special_activity_img.plus_small)
+                if ret1 == False or ret2 == False:
+                    waitClickImg_withBool([monster_img.fight, monster_img.fight2, monster_img.fight3], 1, 0.5)
                     return False
-                cleaned_text = countStr[0].replace('.', '')
-                cleaned_text = cleaned_text.replace(',', '')
-                try:
-                    count = int(cleaned_text)
-                except:
-                    return False
-                print("current power:", count)
-                if count < 15000000:
+                
+                if plusPos[0] - powerPos[0] < 69:
                     return False
+
+
                 waitClickImg_withBool([monster_img.fight, monster_img.fight2, monster_img.fight3], 1, 0.5)
+                return True
             else:
                 if False == waitClickImg_noWait_withBool(monster_img.all_select, 1, 0.5):
                     break
+                myTimeSleep_small()
         return True        
 
 class task_cure(dongri_task):

+ 20 - 0
scriptBase/imgFind.py

@@ -181,6 +181,26 @@ class pcacc_img:
             return False, (-1, -1)
 
     @staticmethod
+    def find_img_origin(image_path):
+        # 设置查找的置信度(confidence)阈值,范围从0到1,默认为0.999
+        confidence_threshold = 0.95
+
+        # 查找模糊图片在屏幕上的位置
+        position = pyautogui.locateOnScreen(image_path, confidence=confidence_threshold)
+
+        if position is not None:
+
+            #dst_position
+            dst_x = position.left
+            dst_y = position.top
+
+            print(f"{image_path}:({dst_x}, {dst_y})")
+            return True, (dst_x, dst_y)
+        else:
+            print(f"{image_path}图片未找到")
+            return False, (-1, -1)
+
+
     def find_img(image_path):
 
         # 设置查找的置信度(confidence)阈值,范围从0到1,默认为0.999

+ 3 - 1
scriptBase/ocr.py

@@ -31,4 +31,6 @@ def capture_and_ocr(region):
         
         # 强制垃圾回收
         import gc
-        gc.collect()
+        gc.collect()
+
+        return ""