Quellcode durchsuchen

fix(CollectiveMissions): Handle reward claims and timeout after donation #7

blylana vor 3 Tagen
Ursprung
Commit
13221d2c0b
1 geänderte Dateien mit 12 neuen und 1 gelöschten Zeilen
  1. 12 1
      tasks/CollectiveMissions/script_task.py

+ 12 - 1
tasks/CollectiveMissions/script_task.py

@@ -264,15 +264,23 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
         logger.info('Swipe to the most matter')
         logger.info('Swipe to the most matter')
         # 还有一点很重要的,捐赠会有双倍的,需要领两次
         # 还有一点很重要的,捐赠会有双倍的,需要领两次
         reward_number = 0
         reward_number = 0
+        check_timer = Timer(5)
+        check_timer.start()
         while 1:
         while 1:
             self.screenshot()
             self.screenshot()
 
 
             if reward_number >= 2:
             if reward_number >= 2:
                 break
                 break
+            if check_timer.reached():
+                logger.warn('Donate timeout')
+                break
             if self.ui_reward_appear_click(False):
             if self.ui_reward_appear_click(False):
+                check_timer.reset()
                 reward_number += 1
                 reward_number += 1
                 continue
                 continue
-            if self.appear_then_click(self.I_CM_PRESENT, interval=1):
+            if self.appear_then_click(self.I_CM_PRESENT, interval=1)\
+                    or self.appear_then_click(self.I_CM_REWARDS, interval=0.5):
+                check_timer.reset()
                 continue
                 continue
         self.ui_reward_appear_click(True)
         self.ui_reward_appear_click(True)
         logger.info('Donate finished')
         logger.info('Donate finished')
@@ -298,6 +306,9 @@ class ScriptTask(GameUi, CollectiveMissionsAssets):
             if click_cnt > 20:
             if click_cnt > 20:
                 logger.warning(f'click_cnt={click_cnt}')
                 logger.warning(f'click_cnt={click_cnt}')
                 return False
                 return False
+            if click_cnt == 8:
+                self.device.click_record_clear()
+
             if not (self.I_CM_SWITCH.match_brightness(self.device.image) and
             if not (self.I_CM_SWITCH.match_brightness(self.device.image) and
                 self.I_CM_SWITCH.match_brightness(self.device.image) and
                 self.I_CM_SWITCH.match_brightness(self.device.image) and
                 self.I_CM_SWITCH.match_mean_color(self.device.image, color=(134, 107, 83))
                 self.I_CM_SWITCH.match_mean_color(self.device.image, color=(134, 107, 83))