mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 00:28:20 +08:00
Rename configs in device, and research
This commit is contained in:
@@ -24,7 +24,7 @@ class Connection:
|
||||
"""
|
||||
logger.hr('Device')
|
||||
self.config = config
|
||||
self.serial = str(self.config.SERIAL)
|
||||
self.serial = str(self.config.Emulator_Serial)
|
||||
self.device = self.connect(self.serial)
|
||||
self.disable_uiautomator2_auto_quit()
|
||||
# if self.config.DEVICE_SCREENSHOT_METHOD == 'aScreenCap':
|
||||
|
||||
@@ -66,14 +66,13 @@ class Control(MiniTouch):
|
||||
logger.info(
|
||||
'Click %s @ %s' % (point2str(x, y), button)
|
||||
)
|
||||
method = self.config.DEVICE_CONTROL_METHOD
|
||||
method = self.config.Emulator_ControlMethod
|
||||
if method == 'minitouch':
|
||||
self._click_minitouch(x, y)
|
||||
elif method == 'uiautomator2':
|
||||
self._click_uiautomator2(x, y)
|
||||
else:
|
||||
self._click_adb(x, y)
|
||||
self.sleep(self.config.SLEEP_AFTER_CLICK)
|
||||
|
||||
@retry()
|
||||
def _click_uiautomator2(self, x, y):
|
||||
@@ -132,7 +131,7 @@ class Control(MiniTouch):
|
||||
logger.info('Swipe distance < 10px, dropped')
|
||||
fx, fy, tx, ty = np.append(start, end).tolist()
|
||||
|
||||
method = self.config.DEVICE_CONTROL_METHOD
|
||||
method = self.config.Emulator_ControlMethod
|
||||
if method == 'minitouch':
|
||||
self._swipe_minitouch(fx, fy, tx, ty)
|
||||
else:
|
||||
@@ -179,7 +178,7 @@ class Control(MiniTouch):
|
||||
|
||||
def drag(self, p1, p2, segments=1, shake=(0, 15), point_random=(-10, -10, 10, 10), shake_random=(-5, -5, 5, 5),
|
||||
swipe_duration=0.25, shake_duration=0.1):
|
||||
method = self.config.DEVICE_CONTROL_METHOD
|
||||
method = self.config.Emulator_ControlMethod
|
||||
if method == 'minitouch':
|
||||
self._drag_minitouch(p1, p2, point_random=point_random)
|
||||
else:
|
||||
|
||||
@@ -8,6 +8,7 @@ from module.device.screenshot import Screenshot
|
||||
from module.exception import GameStuckError
|
||||
from module.handler.assets import GET_MISSION
|
||||
from module.logger import logger
|
||||
from module.config.utils import get_server_next_update
|
||||
import sys
|
||||
|
||||
|
||||
@@ -28,20 +29,19 @@ class Device(Screenshot, Control, AppControl):
|
||||
notification.icon = "assets/gooey/icon.ico"
|
||||
notification.send(block=False)
|
||||
|
||||
def handle_night_commission(self, hour=21, threshold=30):
|
||||
def handle_night_commission(self, daily_trigger='21:00', threshold=30):
|
||||
"""
|
||||
Args:
|
||||
hour (int): Hour that night commission refresh.
|
||||
daily_trigger (int): Time for commission refresh.
|
||||
threshold (int): Seconds around refresh time.
|
||||
|
||||
Returns:
|
||||
bool: If handled.
|
||||
"""
|
||||
update = self.config.get_server_last_update(since=(hour,))
|
||||
now = datetime.now().time()
|
||||
if now < (update - timedelta(seconds=threshold)).time():
|
||||
return False
|
||||
if now > (update + timedelta(seconds=threshold)).time():
|
||||
update = get_server_next_update(daily_trigger=daily_trigger)
|
||||
now = datetime.now()
|
||||
diff = (update.timestamp() - now.timestamp()) % 86400
|
||||
if threshold < diff < 86400 - threshold:
|
||||
return False
|
||||
|
||||
if GET_MISSION.match(self.image, offset=True):
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import os
|
||||
import time
|
||||
from collections import deque
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
|
||||
from PIL import Image
|
||||
from cached_property import cached_property
|
||||
from retrying import retry
|
||||
|
||||
from module.base.timer import Timer
|
||||
@@ -49,7 +51,7 @@ class Screenshot(AScreenCap):
|
||||
screenshot = self.adb_shell(['screencap', '-p'])
|
||||
return self._process_screenshot(screenshot)
|
||||
|
||||
@retry(wait_fixed=5000, stop_max_attempt_number=10)
|
||||
# @retry(wait_fixed=5000, stop_max_attempt_number=10)
|
||||
# @timer
|
||||
def screenshot(self):
|
||||
"""
|
||||
@@ -58,7 +60,7 @@ class Screenshot(AScreenCap):
|
||||
"""
|
||||
self._screenshot_interval_timer.wait()
|
||||
self._screenshot_interval_timer.reset()
|
||||
method = self.config.DEVICE_SCREENSHOT_METHOD
|
||||
method = self.config.Emulator_ControlMethod
|
||||
|
||||
if method == 'aScreenCap':
|
||||
self.image = self._screenshot_ascreencap()
|
||||
@@ -68,11 +70,15 @@ class Screenshot(AScreenCap):
|
||||
self.image = self._screenshot_adb()
|
||||
|
||||
self.image.load()
|
||||
if self.config.ENABLE_ERROR_LOG_AND_SCREENSHOT_SAVE:
|
||||
logger.screenshot_deque.append({'time': datetime.now(), 'image': self.image})
|
||||
if self.config.Error_SaveError:
|
||||
self.screenshot_deque.append({'time': datetime.now(), 'image': self.image})
|
||||
|
||||
return self.image
|
||||
|
||||
@cached_property
|
||||
def screenshot_deque(self):
|
||||
return deque(maxlen=int(self.config.Error_ScreenshotLength))
|
||||
|
||||
def save_screenshot(self, genre='items', interval=None, to_base_folder=False):
|
||||
"""Save a screenshot. Use millisecond timestamp as file name.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user