mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-15 14:37:20 +08:00
@@ -8,6 +8,7 @@ from module.base.decorator import Config
|
||||
from module.base.filter import Filter
|
||||
from module.base.timer import Timer
|
||||
from module.base.utils import *
|
||||
from module.config.config_generated import GeneratedConfig
|
||||
from module.logger import logger
|
||||
from module.ocr.ocr import Ocr
|
||||
from module.research.assets import *
|
||||
@@ -551,9 +552,6 @@ class ResearchSelector(UI):
|
||||
"""
|
||||
We do not need a screenshot here actually. 'image' is a null argument.
|
||||
Adding this argument is just to eusure all "research_detect" have the same arguments.
|
||||
|
||||
Args:
|
||||
image (np.ndarray): Screenshots
|
||||
"""
|
||||
projects = []
|
||||
proj_sorted = []
|
||||
@@ -584,21 +582,18 @@ class ResearchSelector(UI):
|
||||
|
||||
@Config.when(SERVER=None)
|
||||
def research_detect(self):
|
||||
"""
|
||||
Args:
|
||||
image (np.ndarray): Screenshots
|
||||
"""
|
||||
timeout = Timer(3, count=3).start()
|
||||
while 1:
|
||||
projects = research_detect(self.device.image)
|
||||
|
||||
if timeout.reached():
|
||||
logger.warning('Failed to OCR research name after 3 trial, assume correct')
|
||||
break
|
||||
|
||||
if sum([p.valid for p in projects]) == 4 and not projects[0].valid:
|
||||
if sum([p.valid for p in projects]) < 5:
|
||||
# Leftmost research series covered by battle pass info, see #1037
|
||||
logger.info('Wrong research serial on the leftmost project, '
|
||||
'probably because of battle pass info')
|
||||
logger.info('Invalid project detected')
|
||||
logger.info('Probably because of battle pass info or too fast screenshot')
|
||||
# A rare case, poor sleep is acceptable
|
||||
self.device.sleep(1)
|
||||
self.device.screenshot()
|
||||
@@ -618,6 +613,12 @@ class ResearchSelector(UI):
|
||||
preset = self.config.Research_PresetFilter
|
||||
if preset == 'custom':
|
||||
string = self.config.Research_CustomFilter
|
||||
if enforce:
|
||||
value = GeneratedConfig.Research_PresetFilter
|
||||
string = string.split()
|
||||
string.append('>')
|
||||
string.extend(DICT_FILTER_PRESET[value].split())
|
||||
string = " ".join(string)
|
||||
else:
|
||||
if self.config.Research_UseCube == 'always_use' or enforce:
|
||||
if f'{preset}_cube' in DICT_FILTER_PRESET:
|
||||
@@ -628,6 +629,11 @@ class ResearchSelector(UI):
|
||||
string = DICT_FILTER_PRESET[preset]
|
||||
|
||||
logger.attr('Research preset', preset)
|
||||
logger.info('Use cube: {} Use coin: {} Use part: {}'.format(
|
||||
self.config.Research_UseCube,
|
||||
self.config.Research_UseCoin,
|
||||
self.config.Research_UsePart))
|
||||
logger.attr('Allow delay', self.config.Research_AllowDelay)
|
||||
|
||||
# Filter uses `hakuryu`, but allows both `hakuryu` and `hakuryuu`
|
||||
string = string.lower().replace('hakuryuu', 'hakuryu')
|
||||
|
||||
Reference in New Issue
Block a user