mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-21 02:05:35 +08:00
Fix: no poor sleep in fleet_preparation_sidebar_ensure
This commit is contained in:
@@ -2,6 +2,7 @@ import numpy as np
|
|||||||
|
|
||||||
from module.base.button import ButtonGrid
|
from module.base.button import ButtonGrid
|
||||||
from module.base.decorator import Config
|
from module.base.decorator import Config
|
||||||
|
from module.base.timer import Timer
|
||||||
from module.handler.assets import *
|
from module.handler.assets import *
|
||||||
from module.handler.enemy_searching import EnemySearchingHandler
|
from module.handler.enemy_searching import EnemySearchingHandler
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
@@ -49,21 +50,14 @@ class AutoSearchHandler(EnemySearchingHandler):
|
|||||||
origin=(1185, 155 + offset), delta=(0, 111),
|
origin=(1185, 155 + offset), delta=(0, 111),
|
||||||
button_shape=(53, 104), grid_shape=(1, 3), name='FLEET_SIDEBAR')
|
button_shape=(53, 104), grid_shape=(1, 3), name='FLEET_SIDEBAR')
|
||||||
|
|
||||||
def _fleet_preparation_sidebar_click(self, index):
|
def _fleet_preparation_get(self):
|
||||||
"""
|
"""
|
||||||
Args:
|
Returns:
|
||||||
index (int):
|
int:
|
||||||
1 for formation
|
1 for formation
|
||||||
2 for meowfficers
|
2 for meowfficers
|
||||||
3 for auto search setting
|
3 for auto search setting
|
||||||
|
|
||||||
Returns:
|
|
||||||
bool: If changed.
|
|
||||||
"""
|
"""
|
||||||
if index <= 0 or index > 3:
|
|
||||||
logger.warning(f'Sidebar index cannot be clicked, {index}, limit to 1 through 5 only')
|
|
||||||
return False
|
|
||||||
|
|
||||||
current = 0
|
current = 0
|
||||||
total = 0
|
total = 0
|
||||||
sidebar = self._fleet_sidebar()
|
sidebar = self._fleet_sidebar()
|
||||||
@@ -81,46 +75,38 @@ class AutoSearchHandler(EnemySearchingHandler):
|
|||||||
if not current:
|
if not current:
|
||||||
logger.warning('No fleet sidebar active.')
|
logger.warning('No fleet sidebar active.')
|
||||||
logger.attr('Fleet_sidebar', f'{current}/{total}')
|
logger.attr('Fleet_sidebar', f'{current}/{total}')
|
||||||
if current == index:
|
return current
|
||||||
return False
|
|
||||||
|
|
||||||
self.device.click(sidebar[0, index - 1])
|
def fleet_preparation_sidebar_ensure(self, index):
|
||||||
return True
|
|
||||||
|
|
||||||
def fleet_preparation_sidebar_ensure(self, index, skip_first_screenshot=True):
|
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
index (int):
|
index (int):
|
||||||
1 for formation
|
1 for formation
|
||||||
2 for meowfficers
|
2 for meowfficers
|
||||||
3 for auto search setting
|
3 for auto search setting
|
||||||
skip_first_screenshot (bool):
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: whether sidebar could be ensured
|
bool: whether sidebar could be ensured
|
||||||
at most 3 attempts are made before
|
at most 3 attempts are made before
|
||||||
return False otherwise True
|
return False otherwise True
|
||||||
"""
|
"""
|
||||||
if index <= 0 or index > 5:
|
if index <= 0 or index > 5:
|
||||||
logger.warning(f'Sidebar index cannot be ensured, {index}, limit 1 through 5 only')
|
logger.warning(f'Sidebar index cannot be ensured, {index}, limit 1 through 5 only')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
counter = 0
|
interval = Timer(1, count=2)
|
||||||
while 1:
|
sidebar = self._fleet_sidebar()
|
||||||
if skip_first_screenshot:
|
for _ in self.loop(timeout=3):
|
||||||
skip_first_screenshot = False
|
current = self._fleet_preparation_get()
|
||||||
else:
|
if current == index:
|
||||||
self.device.screenshot()
|
|
||||||
|
|
||||||
if self._fleet_preparation_sidebar_click(index):
|
|
||||||
if counter >= 2:
|
|
||||||
logger.warning('Sidebar could not be ensured')
|
|
||||||
return False
|
|
||||||
counter += 1
|
|
||||||
self.device.sleep((0.3, 0.5))
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
return True
|
return True
|
||||||
|
if interval.reached():
|
||||||
|
self.device.click(sidebar[0, index - 1])
|
||||||
|
interval.reset()
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
logger.warning('Sidebar could not be ensured')
|
||||||
|
return False
|
||||||
|
|
||||||
def _auto_search_set_click(self, setting):
|
def _auto_search_set_click(self, setting):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user