mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-05-20 06:02:26 +08:00
@@ -57,18 +57,18 @@ class Config:
|
|||||||
EDGE_LINES_HOUGHLINES_THRESHOLD = 40
|
EDGE_LINES_HOUGHLINES_THRESHOLD = 40
|
||||||
COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5
|
COINCIDENT_POINT_ENCOURAGE_DISTANCE = 1.5
|
||||||
INTERNAL_LINES_FIND_PEAKS_PARAMETERS = {
|
INTERNAL_LINES_FIND_PEAKS_PARAMETERS = {
|
||||||
'height': (120, 255 - 49),
|
'height': (120, 255 - 33),
|
||||||
'width': (1.5, 10),
|
'width': (1.5, 10),
|
||||||
'prominence': 10,
|
'prominence': 10,
|
||||||
'distance': 35,
|
'distance': 35,
|
||||||
}
|
}
|
||||||
EDGE_LINES_FIND_PEAKS_PARAMETERS = {
|
EDGE_LINES_FIND_PEAKS_PARAMETERS = {
|
||||||
'height': (255 - 49, 255),
|
'height': (255 - 33, 255),
|
||||||
'prominence': 10,
|
'prominence': 10,
|
||||||
'distance': 50,
|
'distance': 50,
|
||||||
'wlen': 1000
|
'wlen': 1000
|
||||||
}
|
}
|
||||||
HOMO_EDGE_COLOR_RANGE = (0, 49)
|
HOMO_EDGE_COLOR_RANGE = (0, 33)
|
||||||
HOMO_EDGE_HOUGHLINES_THRESHOLD = 210
|
HOMO_EDGE_HOUGHLINES_THRESHOLD = 210
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class Food:
|
|||||||
|
|
||||||
|
|
||||||
FOOD_FEED_AMOUNT = [1000, 2000, 3000, 5000, 10000, 20000]
|
FOOD_FEED_AMOUNT = [1000, 2000, 3000, 5000, 10000, 20000]
|
||||||
FOOD_FILTER = Filter(regex=re.compile('(\d+)'), attr=['feed'])
|
FOOD_FILTER = Filter(regex=re.compile(r'(\d+)'), attr=['feed'])
|
||||||
|
|
||||||
|
|
||||||
class RewardDorm(UI):
|
class RewardDorm(UI):
|
||||||
@@ -89,7 +89,7 @@ class RewardDorm(UI):
|
|||||||
|
|
||||||
if not self._dorm_has_food(button) \
|
if not self._dorm_has_food(button) \
|
||||||
or self.handle_info_bar() \
|
or self.handle_info_bar() \
|
||||||
or self.handle_popup_cancel('dorm_feed'):
|
or self.handle_popup_cancel('DORM_FEED'):
|
||||||
break
|
break
|
||||||
if timeout.reached():
|
if timeout.reached():
|
||||||
logger.warning('Wait dorm feed timeout')
|
logger.warning('Wait dorm feed timeout')
|
||||||
@@ -111,7 +111,7 @@ class RewardDorm(UI):
|
|||||||
|
|
||||||
if not self._dorm_has_food(button) \
|
if not self._dorm_has_food(button) \
|
||||||
or self.handle_info_bar() \
|
or self.handle_info_bar() \
|
||||||
or self.handle_popup_cancel('dorm_feed'):
|
or self.handle_popup_cancel('DORM_FEED'):
|
||||||
break
|
break
|
||||||
if timeout.reached():
|
if timeout.reached():
|
||||||
logger.warning('Wait dorm feed timeout')
|
logger.warning('Wait dorm feed timeout')
|
||||||
@@ -220,7 +220,7 @@ class RewardDorm(UI):
|
|||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
if self.handle_popup_cancel('dorm_feed'):
|
if self.handle_popup_cancel('DORM_FEED'):
|
||||||
continue
|
continue
|
||||||
# End
|
# End
|
||||||
if self.appear(DORM_FEED_CHECK, offset=(20, 20)):
|
if self.appear(DORM_FEED_CHECK, offset=(20, 20)):
|
||||||
@@ -284,6 +284,52 @@ class RewardDorm(UI):
|
|||||||
logger.warning('Dorm feed run count reached')
|
logger.warning('Dorm feed run count reached')
|
||||||
return 10
|
return 10
|
||||||
|
|
||||||
|
def dorm_feed_enter(self, skip_first_screenshot=False):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: DORM_CHECK
|
||||||
|
out: DORM_FEED_CHECK
|
||||||
|
"""
|
||||||
|
self.interval_clear(DORM_CHECK)
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
# End
|
||||||
|
if self.appear(DORM_FEED_CHECK, offset=(20, 20)):
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.appear(DORM_CHECK, offset=(20, 20), interval=2):
|
||||||
|
self.device.click(DORM_FEED_ENTER)
|
||||||
|
continue
|
||||||
|
if self.ui_additional():
|
||||||
|
continue
|
||||||
|
|
||||||
|
def dorm_feed_quit(self, skip_first_screenshot=False):
|
||||||
|
"""
|
||||||
|
Pages:
|
||||||
|
in: DORM_FEED_CHECK
|
||||||
|
out: DORM_CHECK
|
||||||
|
"""
|
||||||
|
self.interval_clear(DORM_FEED_CHECK)
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
# End
|
||||||
|
if self.appear(DORM_CHECK, offset=(20, 20)):
|
||||||
|
break
|
||||||
|
|
||||||
|
if self.appear(DORM_FEED_CHECK, offset=(20, 20), interval=2):
|
||||||
|
self.device.click(DORM_FEED_ENTER)
|
||||||
|
continue
|
||||||
|
if self.handle_popup_cancel('DORM_FEED'):
|
||||||
|
continue
|
||||||
|
|
||||||
def dorm_run(self, feed=True, collect=True):
|
def dorm_run(self, feed=True, collect=True):
|
||||||
"""
|
"""
|
||||||
Pages:
|
Pages:
|
||||||
@@ -301,15 +347,17 @@ class RewardDorm(UI):
|
|||||||
return
|
return
|
||||||
self.ui_goto(page_dorm, skip_first_screenshot=True)
|
self.ui_goto(page_dorm, skip_first_screenshot=True)
|
||||||
|
|
||||||
if collect:
|
# Feed first to handle DORM_INFO
|
||||||
self.dorm_collect()
|
# DORM_INFO may cover dorm coins and loves
|
||||||
|
|
||||||
if feed:
|
if feed:
|
||||||
self.ui_click(click_button=DORM_FEED_ENTER, appear_button=DORM_CHECK, check_button=DORM_FEED_CHECK,
|
logger.hr('Dorm feed', level=1)
|
||||||
additional=self.ui_additional, retry_wait=3, skip_first_screenshot=True)
|
self.dorm_feed_enter()
|
||||||
self.dorm_feed()
|
self.dorm_feed()
|
||||||
self.ui_click(click_button=DORM_FEED_ENTER, appear_button=DORM_FEED_CHECK, check_button=DORM_CHECK,
|
self.dorm_feed_quit()
|
||||||
skip_first_screenshot=True)
|
|
||||||
|
if collect:
|
||||||
|
logger.hr('Dorm collect', level=1)
|
||||||
|
self.dorm_collect()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -183,8 +183,8 @@ class InfoHandler(ModuleBase):
|
|||||||
else:
|
else:
|
||||||
self.device.screenshot()
|
self.device.screenshot()
|
||||||
|
|
||||||
enabled = self.image_color_count(USE_DATA_KEY_NOTIFIED,
|
enabled = self.image_color_count(
|
||||||
color=(140, 207, 66), threshold=180, count=10)
|
USE_DATA_KEY_NOTIFIED, color=(140, 207, 66), threshold=180, count=10)
|
||||||
if enabled:
|
if enabled:
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -296,6 +296,18 @@ class InfoHandler(ModuleBase):
|
|||||||
|
|
||||||
return buttons
|
return buttons
|
||||||
|
|
||||||
|
def _is_story_black(self):
|
||||||
|
color = get_color(self.device.image, area=STORY_LETTER_BLACK.area)
|
||||||
|
# Story with dark background and a few rows of letters
|
||||||
|
# STORY_LETTER_BLACK.color is (16, 20, 16)
|
||||||
|
if color_similar(color, STORY_LETTER_BLACK.color, threshold=10):
|
||||||
|
return True
|
||||||
|
# Story with black and a few rows of letters
|
||||||
|
if color_similar(color, (0, 0, 0), threshold=10):
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def story_skip(self, drop=None):
|
def story_skip(self, drop=None):
|
||||||
if self.story_popup_timeout.started() and not self.story_popup_timeout.reached():
|
if self.story_popup_timeout.started() and not self.story_popup_timeout.reached():
|
||||||
if self.handle_popup_confirm('STORY_SKIP'):
|
if self.handle_popup_confirm('STORY_SKIP'):
|
||||||
@@ -303,9 +315,10 @@ class InfoHandler(ModuleBase):
|
|||||||
self.interval_reset(STORY_SKIP)
|
self.interval_reset(STORY_SKIP)
|
||||||
self.interval_reset(STORY_LETTERS_ONLY)
|
self.interval_reset(STORY_LETTERS_ONLY)
|
||||||
return True
|
return True
|
||||||
if self.appear(STORY_LETTER_BLACK) and self.appear_then_click(STORY_LETTERS_ONLY, offset=(20, 20), interval=2):
|
if self._is_story_black():
|
||||||
self.story_popup_timeout.reset()
|
if self.appear_then_click(STORY_LETTERS_ONLY, offset=(20, 20), interval=2):
|
||||||
return True
|
self.story_popup_timeout.reset()
|
||||||
|
return True
|
||||||
if self._story_option_timer.reached() and self.appear(STORY_SKIP, offset=(20, 20), interval=0):
|
if self._story_option_timer.reached() and self.appear(STORY_SKIP, offset=(20, 20), interval=0):
|
||||||
options = self._story_option_buttons()
|
options = self._story_option_buttons()
|
||||||
options_count = len(options)
|
options_count = len(options)
|
||||||
|
|||||||
@@ -23,13 +23,25 @@ OCR_OS_ADAPTABILITY = Digit([
|
|||||||
OS_ADAPTABILITY_RECOVER
|
OS_ADAPTABILITY_RECOVER
|
||||||
], letter=(231, 235, 239), lang="cnocr", name='OCR_OS_ADAPTABILITY')
|
], letter=(231, 235, 239), lang="cnocr", name='OCR_OS_ADAPTABILITY')
|
||||||
|
|
||||||
|
|
||||||
|
class ActionPointBuyCounter(DigitCounter):
|
||||||
|
def after_process(self, result):
|
||||||
|
result = super().after_process(result)
|
||||||
|
|
||||||
|
# Possible result: 0/5, 05
|
||||||
|
if result == '05':
|
||||||
|
result = '0/5'
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
if server.server != 'jp':
|
if server.server != 'jp':
|
||||||
# Letters in ACTION_POINT_BUY_REMAIN are not the numeric fonts usually used in azur lane.
|
# Letters in ACTION_POINT_BUY_REMAIN are not the numeric fonts usually used in azur lane.
|
||||||
OCR_ACTION_POINT_BUY_REMAIN = DigitCounter(
|
OCR_ACTION_POINT_BUY_REMAIN = ActionPointBuyCounter(
|
||||||
ACTION_POINT_BUY_REMAIN, letter=(148, 247, 99), lang='cnocr', name='OCR_ACTION_POINT_BUY_REMAIN')
|
ACTION_POINT_BUY_REMAIN, letter=(148, 247, 99), lang='cnocr', name='OCR_ACTION_POINT_BUY_REMAIN')
|
||||||
else:
|
else:
|
||||||
# The color of the digits ACTION_POINT_BUY_REMAIN is white in JP, which is light green in CN and EN.
|
# The color of the digits ACTION_POINT_BUY_REMAIN is white in JP, which is light green in CN and EN.
|
||||||
OCR_ACTION_POINT_BUY_REMAIN = DigitCounter(
|
OCR_ACTION_POINT_BUY_REMAIN = ActionPointBuyCounter(
|
||||||
ACTION_POINT_BUY_REMAIN, letter=(255, 255, 255), lang='cnocr', name='OCR_ACTION_POINT_BUY_REMAIN')
|
ACTION_POINT_BUY_REMAIN, letter=(255, 255, 255), lang='cnocr', name='OCR_ACTION_POINT_BUY_REMAIN')
|
||||||
|
|
||||||
|
|
||||||
@@ -224,6 +236,39 @@ class ActionPointHandler(UI, MapEventHandler):
|
|||||||
logger.warning('Failed to set action point button after 3 trial')
|
logger.warning('Failed to set action point button after 3 trial')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def action_point_get_buy_remain(self, skip_first_screenshot=True):
|
||||||
|
"""
|
||||||
|
Args:
|
||||||
|
skip_first_screenshot:
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
int: Remaining number of purchases of action points
|
||||||
|
|
||||||
|
Pages:
|
||||||
|
in: ACTION_POINT_USE
|
||||||
|
"""
|
||||||
|
timeout = Timer(1, count=2).start()
|
||||||
|
current = 0
|
||||||
|
while 1:
|
||||||
|
if skip_first_screenshot:
|
||||||
|
skip_first_screenshot = False
|
||||||
|
else:
|
||||||
|
self.device.screenshot()
|
||||||
|
|
||||||
|
if timeout.reached():
|
||||||
|
logger.warning('Get action points buy remain timeout')
|
||||||
|
break
|
||||||
|
|
||||||
|
current, _, total = OCR_ACTION_POINT_BUY_REMAIN.ocr(self.device.image)
|
||||||
|
|
||||||
|
# Possible result: 0/5, 05
|
||||||
|
if total == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
break
|
||||||
|
|
||||||
|
return current
|
||||||
|
|
||||||
def action_point_buy(self, preserve=1000):
|
def action_point_buy(self, preserve=1000):
|
||||||
"""
|
"""
|
||||||
Use oil to buy action points.
|
Use oil to buy action points.
|
||||||
@@ -233,9 +278,12 @@ class ActionPointHandler(UI, MapEventHandler):
|
|||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: If bought
|
bool: If bought
|
||||||
|
|
||||||
|
Pages:
|
||||||
|
in: ACTION_POINT_USE
|
||||||
"""
|
"""
|
||||||
self.action_point_set_button(0)
|
self.action_point_set_button(0)
|
||||||
current, _, _ = OCR_ACTION_POINT_BUY_REMAIN.ocr(self.device.image)
|
current = self.action_point_get_buy_remain()
|
||||||
buy_max = 5 # In current version of AL, players can buy 5 times of AP in a week.
|
buy_max = 5 # In current version of AL, players can buy 5 times of AP in a week.
|
||||||
buy_count = buy_max - current
|
buy_count = buy_max - current
|
||||||
buy_limit = self.config.OpsiGeneral_BuyActionPointLimit
|
buy_limit = self.config.OpsiGeneral_BuyActionPointLimit
|
||||||
|
|||||||
@@ -156,6 +156,11 @@ class StorageHandler(GlobeOperation, ZoneManager):
|
|||||||
in: STORAGE_CHECK
|
in: STORAGE_CHECK
|
||||||
out: is_in_map, in an obscure zone.
|
out: is_in_map, in an obscure zone.
|
||||||
"""
|
"""
|
||||||
|
self.interval_clear([
|
||||||
|
STORAGE_CHECK,
|
||||||
|
STORAGE_COORDINATE_CHECKOUT
|
||||||
|
])
|
||||||
|
self.popup_interval_clear()
|
||||||
while 1:
|
while 1:
|
||||||
if skip_first_screenshot:
|
if skip_first_screenshot:
|
||||||
skip_first_screenshot = False
|
skip_first_screenshot = False
|
||||||
|
|||||||
Reference in New Issue
Block a user