|
|
@@ -4,6 +4,7 @@
|
|
|
|
|
|
from time import sleep
|
|
|
|
|
|
+import random
|
|
|
from datetime import datetime, timedelta
|
|
|
from module.atom.animate import RuleAnimate
|
|
|
from module.atom.click import RuleClick
|
|
|
@@ -468,31 +469,30 @@ class BaseTask(GlobalGameAssets, CostumeBase):
|
|
|
:param name:
|
|
|
:return:
|
|
|
"""
|
|
|
- if target.is_image:
|
|
|
- while True:
|
|
|
- self.screenshot()
|
|
|
+ swipe_down = False
|
|
|
+ swipe_distance_ratio = None
|
|
|
+ result = None
|
|
|
+ if not target:
|
|
|
+ return False
|
|
|
+ while True:
|
|
|
+ self.screenshot()
|
|
|
+ if target.is_image:
|
|
|
result = target.image_appear(self.device.image, name=name)
|
|
|
- if result is not None:
|
|
|
- return result
|
|
|
- x1, y1, x2, y2 = target.swipe_pos()
|
|
|
- self.device.swipe(p1=(x1, y1), p2=(x2, y2))
|
|
|
-
|
|
|
- elif target.is_ocr:
|
|
|
- while True:
|
|
|
- self.screenshot()
|
|
|
+ swipe_down = True
|
|
|
+ elif target.is_ocr:
|
|
|
result = target.ocr_appear(self.device.image, name=name)
|
|
|
- if isinstance(result, tuple):
|
|
|
- return result
|
|
|
-
|
|
|
- after = True
|
|
|
- if isinstance(result, int) and result > 0:
|
|
|
- after = True
|
|
|
- elif isinstance(result, int) and result < 0:
|
|
|
- after = False
|
|
|
-
|
|
|
- x1, y1, x2, y2 = target.swipe_pos(number=1, after=after)
|
|
|
- self.device.swipe(p1=(x1, y1), p2=(x2, y2))
|
|
|
- sleep(1) # 等待滑动完成, 还没想好如何优化
|
|
|
+ swipe_down = isinstance(result, int) and result > 0
|
|
|
+ swipe_distance_ratio = 1
|
|
|
+ if not result:
|
|
|
+ return False
|
|
|
+ if isinstance(result, tuple):
|
|
|
+ return result
|
|
|
+ if swipe_distance_ratio:
|
|
|
+ x1, y1, x2, y2 = target.swipe_pos(number=swipe_distance_ratio, after=swipe_down)
|
|
|
+ else:
|
|
|
+ x1, y1, x2, y2 = target.swipe_pos(after=swipe_down)
|
|
|
+ self.device.swipe(p1=(x1, y1), p2=(x2, y2))
|
|
|
+ sleep(random.uniform(0.8, 1.3)) # 等待滑动完成, 待优化
|
|
|
|
|
|
def list_appear_click(self, target: RuleList) -> bool:
|
|
|
appear = self.list_find(target, name=target.array[0])
|