mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-16 05:47:23 +08:00
Fix: Add retry on getting OpSi fleet
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
|
from module.base.decorator import cached_property
|
||||||
from module.base.timer import Timer
|
from module.base.timer import Timer
|
||||||
from module.base.utils import *
|
from module.base.utils import *
|
||||||
|
from module.exception import ScriptError
|
||||||
from module.logger import logger
|
from module.logger import logger
|
||||||
from module.os.assets import *
|
from module.os.assets import *
|
||||||
from module.ui.ui import UI
|
from module.ui.ui import UI
|
||||||
from module.base.decorator import cached_property
|
|
||||||
|
|
||||||
class FleetSelector:
|
class FleetSelector:
|
||||||
"""
|
"""
|
||||||
@@ -25,14 +27,14 @@ class FleetSelector:
|
|||||||
def get(self):
|
def get(self):
|
||||||
"""
|
"""
|
||||||
Returns:
|
Returns:
|
||||||
int: Index of current fleet, 1 to 4.
|
int: Index of current fleet, 1 to 4. return 0 if unrecognised.
|
||||||
"""
|
"""
|
||||||
for index, button in enumerate([FLEET_1, FLEET_2, FLEET_3, FLEET_4]):
|
for index, button in enumerate([FLEET_1, FLEET_2, FLEET_3, FLEET_4]):
|
||||||
if self.main.appear(button, offset=(20, 20)):
|
if self.main.appear(button, offset=(20, 20)):
|
||||||
return index + 1
|
return index + 1
|
||||||
|
|
||||||
logger.warning('Unknown current fleet, assuming it is fleet 1')
|
logger.info('Unknown OpSi fleet')
|
||||||
return 1
|
return 0
|
||||||
|
|
||||||
def bar_opened(self):
|
def bar_opened(self):
|
||||||
# Check the 3-13 column
|
# Check the 3-13 column
|
||||||
@@ -171,14 +173,22 @@ class FleetSelector:
|
|||||||
Returns:
|
Returns:
|
||||||
bool: If fleet switched.
|
bool: If fleet switched.
|
||||||
"""
|
"""
|
||||||
if self.get() == index:
|
for _ in range(10):
|
||||||
logger.info(f'It is fleet {index} already')
|
current = self.get()
|
||||||
return False
|
if current == index:
|
||||||
else:
|
logger.info(f'It is fleet {index} already')
|
||||||
logger.info(f'Ensure fleet to be {index}')
|
return False
|
||||||
self.open()
|
elif current > 0:
|
||||||
self.click(index)
|
logger.info(f'Ensure fleet to be {index}')
|
||||||
return True
|
self.open()
|
||||||
|
self.click(index)
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
self.main.device.screenshot()
|
||||||
|
continue
|
||||||
|
|
||||||
|
logger.warning('Unknown OpSi fleet')
|
||||||
|
raise ScriptError('Unknown OpSi fleet')
|
||||||
|
|
||||||
|
|
||||||
class OSFleetSelector(UI):
|
class OSFleetSelector(UI):
|
||||||
|
|||||||
Reference in New Issue
Block a user