1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-05-22 01:57:51 +08:00

Merge pull request #262 from nEEtdo0d/revised_enhance

Opt: Revise enhancement module
This commit is contained in:
Kyo
2020-12-16 02:46:05 -03:00
committed by GitHub
15 changed files with 157 additions and 163 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -52,6 +52,7 @@ retire_method = one_click_retire
retire_amount = retire_all retire_amount = retire_all
enhance_favourite = no enhance_favourite = no
enhance_order_string = enhance_order_string =
enhance_check_per_category = 2
retire_n = yes retire_n = yes
retire_r = no retire_r = no
enable_drop_screenshot = no enable_drop_screenshot = no

View File

@@ -217,6 +217,9 @@ def main(ini_name=''):
retire.add_argument('--退役数量', default=default('--退役数量'), choices=['退役全部', '退役10个'], gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--退役数量', default=default('--退役数量'), choices=['退役全部', '退役10个'], gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--强化常用角色', default=default('--强化常用角色'), choices=['', ''], gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--强化常用角色', default=default('--强化常用角色'), choices=['', ''], gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--强化过滤字符串', default=default('--强化过滤字符串'), help='格式: "cv > bb > ...", 留空则使用默认强化方式', gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--强化过滤字符串', default=default('--强化过滤字符串'), help='格式: "cv > bb > ...", 留空则使用默认强化方式', gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--enhance_check_per_category', default=default('--enhance_check_per_category'),
help='How many ships at maximum are viewed before moving onto the next category, ships that are \'in battle\' do not count towards this number and are skipped to the next available ship for enhancement',
gooey_options={'label_color': '#4B5F83'})
rarity = retire.add_argument_group('退役稀有度', '暂不支持舰种选择, 使用一键退役时忽略以下选项', gooey_options={'label_color': '#931D03'}) rarity = retire.add_argument_group('退役稀有度', '暂不支持舰种选择, 使用一键退役时忽略以下选项', gooey_options={'label_color': '#931D03'})
rarity.add_argument('--退役白皮', default=default('--退役白皮'), choices=['', ''], help='N', gooey_options={'label_color': '#4B5F83'}) rarity.add_argument('--退役白皮', default=default('--退役白皮'), choices=['', ''], help='N', gooey_options={'label_color': '#4B5F83'})

View File

@@ -217,7 +217,12 @@ def main(ini_name=''):
retire.add_argument('--retire_method', default=default('--retire_method'), choices=['enhance', 'one_click_retire', 'old_retire'], help='If choosing enhance, when not having enough enhance material, will use one click retire', gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--retire_method', default=default('--retire_method'), choices=['enhance', 'one_click_retire', 'old_retire'], help='If choosing enhance, when not having enough enhance material, will use one click retire', gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--retire_amount', default=default('--retire_amount'), choices=['retire_all', 'retire_10'], gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--retire_amount', default=default('--retire_amount'), choices=['retire_all', 'retire_10'], gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--enhance_favourite', default=default('--enhance_favourite'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--enhance_favourite', default=default('--enhance_favourite'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--enhance_order_string', default=default('--enhance_order_string'), help='Use example format "cv > bb > ..." may omit a ship type category altogether to skip otherwise leave blank to use default enhance method', gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--enhance_order_string', default=default('--enhance_order_string'),
help='Use example format "cv > bb > ..." may omit a ship type category altogether to skip otherwise leave blank to not apply any filter. Using \'?\' will have ALAS select a category at random, may use multiple in same string',
gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--enhance_check_per_category', default=default('--enhance_check_per_category'),
help='How many ships at maximum are viewed before moving onto the next category, ships that are \'in battle\' do not count towards this number and are skipped to the next available ship for enhancement',
gooey_options={'label_color': '#4B5F83'})
rarity = retire.add_argument_group('Retirement rarity', 'The ship type selection is not supported yet. Ignore the following options when using one-key retirement', gooey_options={'label_color': '#4B5F83'}) rarity = retire.add_argument_group('Retirement rarity', 'The ship type selection is not supported yet. Ignore the following options when using one-key retirement', gooey_options={'label_color': '#4B5F83'})
rarity.add_argument('--retire_n', default=default('--retire_n'), choices=['yes', 'no'], help='N', gooey_options={'label_color': '#4B5F83'}) rarity.add_argument('--retire_n', default=default('--retire_n'), choices=['yes', 'no'], help='N', gooey_options={'label_color': '#4B5F83'})

View File

@@ -217,7 +217,12 @@ def main(ini_name=''):
retire.add_argument('--retire_method', default=default('--retire_method'), choices=['enhance', 'one_click_retire', 'old_retire'], help='If choosing enhance, when not having enough enhance material, will use one click retire', gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--retire_method', default=default('--retire_method'), choices=['enhance', 'one_click_retire', 'old_retire'], help='If choosing enhance, when not having enough enhance material, will use one click retire', gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--retire_amount', default=default('--retire_amount'), choices=['retire_all', 'retire_10'], gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--retire_amount', default=default('--retire_amount'), choices=['retire_all', 'retire_10'], gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--enhance_favourite', default=default('--enhance_favourite'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--enhance_favourite', default=default('--enhance_favourite'), choices=['yes', 'no'], gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--enhance_order_string', default=default('--enhance_order_string'), help='Use example format "cv > bb > ..." may omit a ship type category altogether to skip otherwise leave blank to use default enhance method', gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--enhance_order_string', default=default('--enhance_order_string'),
help='Use example format "cv > bb > ..." may omit a ship type category altogether to skip otherwise leave blank to not apply any filter. Using \'?\' will have ALAS select a category at random, may use multiple in same string',
gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--enhance_check_per_category', default=default('--enhance_check_per_category'),
help='How many ships at maximum are viewed before moving onto the next category, ships that are \'in battle\' do not count towards this number and are skipped to the next available ship for enhancement',
gooey_options={'label_color': '#4B5F83'})
rarity = retire.add_argument_group('Retirement rarity', 'The ship type selection is not supported yet. Ignore the following options when using one-key retirement', gooey_options={'label_color': '#4B5F83'}) rarity = retire.add_argument_group('Retirement rarity', 'The ship type selection is not supported yet. Ignore the following options when using one-key retirement', gooey_options={'label_color': '#4B5F83'})
rarity.add_argument('--retire_n', default=default('--retire_n'), choices=['yes', 'no'], help='N', gooey_options={'label_color': '#4B5F83'}) rarity.add_argument('--retire_n', default=default('--retire_n'), choices=['yes', 'no'], help='N', gooey_options={'label_color': '#4B5F83'})

View File

@@ -217,6 +217,9 @@ def main(ini_name=''):
retire.add_argument('--退役數量', default=default('--退役數量'), choices=['退役全部', '退役10個'], gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--退役數量', default=default('--退役數量'), choices=['退役全部', '退役10個'], gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--強化常用角色', default=default('--強化常用角色'), choices=['', ''], gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--強化常用角色', default=default('--強化常用角色'), choices=['', ''], gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--強化過濾字符串', default=default('--強化過濾字符串'), help='格式: "cv > bb > ...", 留空則使用默認強化方式', gooey_options={'label_color': '#4B5F83'}) retire.add_argument('--強化過濾字符串', default=default('--強化過濾字符串'), help='格式: "cv > bb > ...", 留空則使用默認強化方式', gooey_options={'label_color': '#4B5F83'})
retire.add_argument('--enhance_check_per_category', default=default('--enhance_check_per_category'),
help='How many ships at maximum are viewed before moving onto the next category, ships that are \'in battle\' do not count towards this number and are skipped to the next available ship for enhancement',
gooey_options={'label_color': '#4B5F83'})
rarity = retire.add_argument_group('退役稀有度', '暫不支援艦種選擇, 使用一鍵退役時忽略以下選項', gooey_options={'label_color': '#931D03'}) rarity = retire.add_argument_group('退役稀有度', '暫不支援艦種選擇, 使用一鍵退役時忽略以下選項', gooey_options={'label_color': '#931D03'})
rarity.add_argument('--退役白皮', default=default('--退役白皮'), choices=['', ''], help='N', gooey_options={'label_color': '#4B5F83'}) rarity.add_argument('--退役白皮', default=default('--退役白皮'), choices=['', ''], help='N', gooey_options={'label_color': '#4B5F83'})

View File

@@ -294,6 +294,7 @@ class AzurLaneConfig:
RETIREMENT_METHOD = 'one_click_retire' # enhance, old_retire, one_click_retire RETIREMENT_METHOD = 'one_click_retire' # enhance, old_retire, one_click_retire
ENHANCE_FAVOURITE = False ENHANCE_FAVOURITE = False
ENHANCE_ORDER_STRING = '' ENHANCE_ORDER_STRING = ''
ENHANCE_CHECK_PER_CATEGORY = 2
DOCK_FULL_TRIGGERED = False DOCK_FULL_TRIGGERED = False
GET_SHIP_TRIGGERED = False GET_SHIP_TRIGGERED = False
RETIRE_AMOUNT = 'all' # all, 10 RETIRE_AMOUNT = 'all' # all, 10
@@ -602,6 +603,7 @@ class AzurLaneConfig:
self.RETIRE_AMOUNT = option['retire_amount'].split('_')[1] self.RETIRE_AMOUNT = option['retire_amount'].split('_')[1]
self.ENHANCE_FAVOURITE = to_bool(option['enhance_favourite']) self.ENHANCE_FAVOURITE = to_bool(option['enhance_favourite'])
self.ENHANCE_ORDER_STRING = option['enhance_order_string'] self.ENHANCE_ORDER_STRING = option['enhance_order_string']
self.ENHANCE_CHECK_PER_CATEGORY = int(option['enhance_check_per_category'])
for r in ['n', 'r']: for r in ['n', 'r']:
self.__setattr__(f'RETIRE_{r.upper()}', to_bool(option[f'retire_{r}'])) self.__setattr__(f'RETIRE_{r.upper()}', to_bool(option[f'retire_{r}']))

View File

@@ -97,6 +97,7 @@ dic_true_eng_to_eng = {
'retire_amount': 'retire_amount', 'retire_amount': 'retire_amount',
'enhance_favourite': 'enhance_favourite', 'enhance_favourite': 'enhance_favourite',
'enhance_order_string': 'enhance_order_string', 'enhance_order_string': 'enhance_order_string',
'enhance_check_per_category': 'enhance_check_per_category',
'retire_n': 'retire_n', 'retire_n': 'retire_n',
'retire_r': 'retire_r', 'retire_r': 'retire_r',
# 'retire_sr': 'retire_sr', # 'retire_sr': 'retire_sr',
@@ -358,6 +359,7 @@ dic_chi_to_eng = {
'退役数量': 'retire_amount', '退役数量': 'retire_amount',
'强化常用角色': 'enhance_favourite', '强化常用角色': 'enhance_favourite',
'强化过滤字符串': 'enhance_order_string', '强化过滤字符串': 'enhance_order_string',
'enhance_check_per_category': 'enhance_check_per_category',
'退役白皮': 'retire_n', '退役白皮': 'retire_n',
'退役蓝皮': 'retire_r', '退役蓝皮': 'retire_r',
# '退役紫皮': 'retire_sr', # '退役紫皮': 'retire_sr',
@@ -619,6 +621,7 @@ dic_tchi_to_eng = {
'退役數量': 'retire_amount', '退役數量': 'retire_amount',
'強化常用角色': 'enhance_favourite', '強化常用角色': 'enhance_favourite',
'強化過濾字符串': 'enhance_order_string', '強化過濾字符串': 'enhance_order_string',
'enhance_check_per_category': 'enhance_check_per_category',
'退役白皮': 'retire_n', '退役白皮': 'retire_n',
'退役藍皮': 'retire_r', '退役藍皮': 'retire_r',
# '退役紫皮': 'retire_sr', # '退役紫皮': 'retire_sr',

View File

@@ -1,13 +1,40 @@
import numpy as np import numpy as np
from random import choice
from module.base.timer import Timer from module.base.timer import Timer
from module.base.utils import color_bar_percentage from module.base.utils import color_bar_percentage
from module.combat.assets import GET_ITEMS_1
from module.logger import logger from module.logger import logger
from module.combat.assets import GET_ITEMS_1
from module.retire.assets import * from module.retire.assets import *
from module.template.assets import TEMPLATE_ENHANCE_SUCCESS, TEMPLATE_ENHANCE_FAILED, TEMPLATE_ENHANCE_IN_BATTLE
from module.handler.assets import INFO_BAR_DETECT
from module.retire.dock import Dock, CARD_GRIDS from module.retire.dock import Dock, CARD_GRIDS
VALID_SHIP_TYPES = ['dd', 'ss', 'cl', 'ca', 'bb', 'cv', 'repair', 'others']
def enhance_letter_preprocess(image):
"""
Args:
image (np.ndarray):
Returns:
np.ndarray
"""
image = image.astype(float)
image = (image - 64) / 0.75
image[image > 255] = 255
image[image < 0] = 0
image = image.astype('uint8')
return image
TEMPLATE_ENHANCE_SUCCESS.image = enhance_letter_preprocess(TEMPLATE_ENHANCE_SUCCESS.image)
TEMPLATE_ENHANCE_FAILED.image = enhance_letter_preprocess(TEMPLATE_ENHANCE_FAILED.image)
TEMPLATE_ENHANCE_IN_BATTLE.image = enhance_letter_preprocess(TEMPLATE_ENHANCE_IN_BATTLE.image)
class Enhancement(Dock): class Enhancement(Dock):
@property @property
def _retire_amount(self): def _retire_amount(self):
@@ -63,193 +90,119 @@ class Enhancement(Dock):
self.dock_filter_set(category='index', type='all', enable=True) self.dock_filter_set(category='index', type='all', enable=True)
self.dock_filter_confirm() self.dock_filter_confirm()
def _enhance_confirm(self): def _enhance_confirm(self, skip_first_screenshot=True):
""" """
Pages: Pages:
in: EQUIP_CONFIRM in: EQUIP_CONFIRM
out: page_ship_enhance, without info_bar out: page_ship_enhance, without info_bar
""" """
executed = False
while 1:
self.device.screenshot()
# if self.appear_then_click(ENHANCE_CONFIRM, offset=(30, 30), interval=3): confirm_timer = Timer(1.5, count=3).start()
# continue while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else:
self.device.screenshot()
if self.appear_then_click(EQUIP_CONFIRM, offset=(30, 30), interval=3): if self.appear_then_click(EQUIP_CONFIRM, offset=(30, 30), interval=3):
confirm_timer.reset()
continue continue
if self.appear_then_click(EQUIP_CONFIRM_2, offset=(30, 30), interval=3): if self.appear_then_click(EQUIP_CONFIRM_2, offset=(30, 30), interval=3):
confirm_timer.reset()
continue continue
if self.appear(GET_ITEMS_1, interval=2): if self.appear(GET_ITEMS_1, interval=2):
self.device.click(GET_ITEMS_1_RETIREMENT_SAVE) self.device.click(GET_ITEMS_1_RETIREMENT_SAVE)
self.interval_reset(ENHANCE_CONFIRM) self.interval_reset(ENHANCE_CONFIRM)
executed = True confirm_timer.reset()
continue continue
# End # End
if executed and self.appear(ENHANCE_CONFIRM, offset=(30, 30)): if self.appear(ENHANCE_CONFIRM, offset=(30, 30)):
self.ensure_no_info_bar() if confirm_timer.reached():
break break
else:
confirm_timer.reset()
def _enhance_choose(self, skip_first_screenshot=True): def _enhance_choose(self, ship_count):
""" """
Re-vamped implementation, utilizing
templates and info_bar text to determine
whether a ship can or cannot be enhanced
Method similar to ambush.py
Pages: Pages:
in: page_ship_enhance, without info_bar in: page_ship_enhance, without info_bar
out: EQUIP_CONFIRM out: EQUIP_CONFIRM
Args:
ship_count (int): ship_count, must be
non-zero positive integer
Returns:
True if able to enhance otherwise False
Always paired with current ship_count
""" """
end_activate_timer = Timer(2, count=2) if self.config.DEVICE_CONTROL_METHOD == 'minitouch' else Timer(2, count=1) skip_until_ensured = True
trapped_timer = Timer(15, count=3).start() enhanced = False
trapped = False
while 1: while 1:
if skip_first_screenshot: # Base Case: No more ships left to check for this category
skip_first_screenshot = False if ship_count <= 0:
else: logger.info('Reached maximum number to check, exiting current category')
self.device.screenshot() return False, ship_count
if self.appear(EQUIP_CONFIRM, offset=(30, 30)): if skip_until_ensured:
return True if not self.equip_sidebar_ensure(index=4):
if not end_activate_timer.reached_and_reset():
continue
ensured = self.equip_sidebar_ensure(index=4)
if ensured:
self.wait_until_appear(ENHANCE_RECOMMEND, offset=(5, 5), skip_first_screenshot=True)
else:
continue
status = color_bar_percentage(self.device.image, area=ENHANCE_RELOAD.area, prev_color=(231, 178, 74))
logger.attr('Reload_enhanced', f'{int(status * 100)}%')
choose = np.sum(np.array(self.device.image.crop(ENHANCE_FILLED.area)) > 200) > 100
if trapped or self.info_bar_count():
if status > 0.98:
logger.info('Fully enhanced for this ship')
swiped = self.equip_view_next(check_button=ENHANCE_RECOMMEND)
self.ensure_no_info_bar()
if not swiped:
return False
trapped_timer.reset()
trapped = False
continue continue
else: self.wait_until_appear(ENHANCE_RECOMMEND, offset=(5, 5), skip_first_screenshot=True)
if choose: skip_until_ensured = False
logger.info('Unable to enhance this ship')
swiped = self.equip_view_next(check_button=ENHANCE_RECOMMEND)
self.ensure_no_info_bar()
if not swiped:
return False
trapped_timer.reset()
trapped = False
continue
else:
logger.info('Enhancement material exhausted')
return False
if not trapped_timer.reached_and_reset() and self.appear_then_click(ENHANCE_RECOMMEND, offset=(5, 5), interval=2):
self.device.sleep(0.3)
self.device.click(ENHANCE_CONFIRM)
else:
logger.warning('Current status appears trapped, will force stat gauge check')
trapped = True
def _enhance_choose_simple(self, current_index=0, skip_first_screenshot=True):
"""
Description:
Simplified _enhance_choose focuses only on
appearance of info_bars, stat gauge is ignored
Minimum 2 times before swiping, if maximum of
4 times is detected, a forced swipe is initiated
A maximum of 4 ships will be checked to account
for 'in battle' status, hard-coded otherwise if
desired can be configurable
Pages:
in: page_ship_enhance, without info_bar
out: EQUIP_CONFIRM
"""
end_activate_timer = Timer(2, count=2) if self.config.DEVICE_CONTROL_METHOD == 'minitouch' else Timer(2, count=1)
next_timer = Timer(2, count=1).start()
trapped_timer = Timer(15, count=3).start()
trapped = False
while 1:
if skip_first_screenshot:
skip_first_screenshot = False
else: else:
self.device.screenshot() self.device.screenshot()
if self.appear(EQUIP_CONFIRM, offset=(30, 30)): # Respond accordingly based on info_bar information
return True, current_index if self.info_bar_count():
image = enhance_letter_preprocess(np.array(self.device.image.crop(INFO_BAR_DETECT.area)))
if not end_activate_timer.reached_and_reset(): if TEMPLATE_ENHANCE_SUCCESS.match(image):
continue enhanced = True
elif TEMPLATE_ENHANCE_FAILED.match(image):
ensured = self.equip_sidebar_ensure(index=4) logger.info('Enhancement failed. Swiping to next ship if feasible')
if ensured:
self.wait_until_appear(ENHANCE_RECOMMEND, offset=(5, 5), skip_first_screenshot=True)
else:
continue
if trapped or self.info_bar_count():
if trapped or next_timer.reached():
logger.info('Unable to enhance this ship, swipe to next')
swiped = self.equip_view_next(check_button=ENHANCE_RECOMMEND)
self.ensure_no_info_bar() self.ensure_no_info_bar()
if not swiped or current_index >= 3: if self.equip_view_next(check_button=ENHANCE_RECOMMEND):
logger.info('Cannot swipe or ship check threshold reached, exiting current category') skip_iteration = True
return False, current_index ship_count -= 1
else:
next_timer.reset()
trapped_timer.reset()
trapped = False
logger.info(f'Try next ship: {3 - current_index}/3 remaining until give up')
current_index += 1
continue continue
else:
logger.info('Swiped failed, exiting current category')
return False, ship_count
elif TEMPLATE_ENHANCE_IN_BATTLE.match(image):
logger.info('Enhancement impossible, ship currently in battle. Swiping to next ship if feasible')
self.ensure_no_info_bar()
if self.equip_view_next(check_button=ENHANCE_RECOMMEND):
skip_iteration = True
continue
else:
logger.info('Swiped failed, exiting current category')
return False, ship_count
if not trapped_timer.reached_and_reset() and self.appear_then_click(ENHANCE_RECOMMEND, offset=(5, 5), interval=2):
# Possible trapped case in which info_bar will never appear
# so long as EQUIP_CONFIRM remains appeared
if enhanced or self.appear(EQUIP_CONFIRM, offset=(30, 30)):
logger.info('Enhancement Successful')
return True, ship_count
# Perform actions to attempt enhancement
if self.appear_then_click(ENHANCE_RECOMMEND, offset=(5, 5), interval=2):
self.device.sleep(0.3) self.device.sleep(0.3)
self.device.click(ENHANCE_CONFIRM) self.device.click(ENHANCE_CONFIRM)
else: logger.info('Enhancing...')
logger.warning('Current status appears trapped, will force swipe to next ship')
trapped = True
def enhance_ships(self, favourite=None): def enhance_ships(self, favourite=None):
""" """
Pages: Enhance target ships by specified order
in: page_dock of types listed in ENHANCE_ORDER_STRING
out: page_dock
Args: Invalid types are treated as requesting
favourite (bool): from ALAS to choose a valid one at random
Returns:
int: total enhanced
"""
if favourite is None:
favourite = self.config.ENHANCE_FAVOURITE
logger.hr('Enhancement')
logger.info(f'Favourite={favourite}')
self._enhance_enter(favourite=favourite)
total = 0
# At least one card present, able to enhance
if self._enhance_enter(favourite=favourite):
while 1:
if not self._enhance_choose():
break
self._enhance_confirm()
total += 10
if total >= self._retire_amount:
break
self._enhance_quit()
return total
def enhance_ships_order(self, favourite=None):
"""
Info:
Target ships in order of specified
type listing by ENHANCE_ORDER_STRING
Pages: Pages:
in: page_dock in: page_dock
@@ -267,25 +220,41 @@ class Enhancement(Dock):
logger.hr('Enhancement by type') logger.hr('Enhancement by type')
total = 0 total = 0
# Process ENHANCE_ORDER_STRING if any into ship_types
ship_types = [s.strip().lower() for s in self.config.ENHANCE_ORDER_STRING.split('>')] ship_types = [s.strip().lower() for s in self.config.ENHANCE_ORDER_STRING.split('>')]
enable_simple = True ship_types = list(filter(('').__ne__, ship_types))
if ship_types == ['']: if len(ship_types) == 0:
enable_simple = False
ship_types = [None] ship_types = [None]
logger.attr('Enhance Order', ship_types) logger.attr('Enhance Order', ship_types)
# Process available ship types for choice randomization
# Removing types that have already been specified by
# ENHANCE_ORDER_STRING
available_ship_types = VALID_SHIP_TYPES.copy()
[available_ship_types.remove(s) for s in ship_types if s in available_ship_types]
for ship_type in ship_types: for ship_type in ship_types:
index = 0 # Helper variable only for _enhance_choose_simple # None check, do not execute if is None
# Otherwise, select a type at random since
# user has specified an unrecognized type
if ship_type is not None and ship_type not in VALID_SHIP_TYPES:
if len(available_ship_types) == 0:
logger.info('No more ship types for ALAS to choose from, skipping iteration')
continue
ship_type = choice(available_ship_types)
available_ship_types.remove(ship_type)
logger.info(f'Favourite={favourite}, Ship Type={ship_type}') logger.info(f'Favourite={favourite}, Ship Type={ship_type}')
# Continue if at least 1 CARD_GRID is selectable
# otherwise skip to next ship type
if not self._enhance_enter(favourite=favourite, ship_type=ship_type): if not self._enhance_enter(favourite=favourite, ship_type=ship_type):
logger.hr(f'Dock Empty by ship type {ship_type}') logger.hr(f'Dock Empty by ship type {ship_type}')
continue continue
current_count = self.config.ENHANCE_CHECK_PER_CATEGORY
while 1: while 1:
if enable_simple: choose_result, current_count = self._enhance_choose(ship_count=current_count)
choose_result, index = self._enhance_choose_simple(current_index=index)
else:
choose_result = self._enhance_choose()
if not choose_result: if not choose_result:
break break
self._enhance_confirm() self._enhance_confirm()
@@ -309,9 +278,9 @@ class Enhancement(Dock):
self.ui_click(RETIRE_APPEAR_3, check_button=DOCK_FILTER, skip_first_screenshot=True) self.ui_click(RETIRE_APPEAR_3, check_button=DOCK_FILTER, skip_first_screenshot=True)
self.handle_dock_cards_loading() self.handle_dock_cards_loading()
total = self.enhance_ships_order() total = self.enhance_ships()
self.dock_quit() self.dock_quit()
self.config.DOCK_FULL_TRIGGERED = True self.config.DOCK_FULL_TRIGGERED = True
return total return total

View File

@@ -18,6 +18,9 @@ TEMPLATE_ENEMY_M = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_M.p
TEMPLATE_ENEMY_Main = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_Main.png', 'en': './assets/en/template/TEMPLATE_ENEMY_Main.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_Main.png', 'tw': './assets/tw/template/TEMPLATE_ENEMY_Main.png'}) TEMPLATE_ENEMY_Main = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_Main.png', 'en': './assets/en/template/TEMPLATE_ENEMY_Main.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_Main.png', 'tw': './assets/tw/template/TEMPLATE_ENEMY_Main.png'})
TEMPLATE_ENEMY_S = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_S.png', 'en': './assets/en/template/TEMPLATE_ENEMY_S.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_S.png', 'tw': './assets/tw/template/TEMPLATE_ENEMY_S.png'}) TEMPLATE_ENEMY_S = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_S.png', 'en': './assets/en/template/TEMPLATE_ENEMY_S.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_S.png', 'tw': './assets/tw/template/TEMPLATE_ENEMY_S.png'})
TEMPLATE_ENEMY_Treasure = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_Treasure.png', 'en': './assets/en/template/TEMPLATE_ENEMY_Treasure.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_Treasure.png', 'tw': './assets/tw/template/TEMPLATE_ENEMY_Treasure.png'}) TEMPLATE_ENEMY_Treasure = Template(file={'cn': './assets/cn/template/TEMPLATE_ENEMY_Treasure.png', 'en': './assets/en/template/TEMPLATE_ENEMY_Treasure.png', 'jp': './assets/jp/template/TEMPLATE_ENEMY_Treasure.png', 'tw': './assets/tw/template/TEMPLATE_ENEMY_Treasure.png'})
TEMPLATE_ENHANCE_FAILED = Template(file={'cn': './assets/cn/template/TEMPLATE_ENHANCE_FAILED.png', 'en': './assets/en/template/TEMPLATE_ENHANCE_FAILED.png', 'jp': './assets/cn/template/TEMPLATE_ENHANCE_FAILED.png', 'tw': './assets/cn/template/TEMPLATE_ENHANCE_FAILED.png'})
TEMPLATE_ENHANCE_IN_BATTLE = Template(file={'cn': './assets/cn/template/TEMPLATE_ENHANCE_IN_BATTLE.png', 'en': './assets/en/template/TEMPLATE_ENHANCE_IN_BATTLE.png', 'jp': './assets/cn/template/TEMPLATE_ENHANCE_IN_BATTLE.png', 'tw': './assets/cn/template/TEMPLATE_ENHANCE_IN_BATTLE.png'})
TEMPLATE_ENHANCE_SUCCESS = Template(file={'cn': './assets/cn/template/TEMPLATE_ENHANCE_SUCCESS.png', 'en': './assets/en/template/TEMPLATE_ENHANCE_SUCCESS.png', 'jp': './assets/cn/template/TEMPLATE_ENHANCE_SUCCESS.png', 'tw': './assets/cn/template/TEMPLATE_ENHANCE_SUCCESS.png'})
TEMPLATE_FLEET_AMMO = Template(file={'cn': './assets/cn/template/TEMPLATE_FLEET_AMMO.png', 'en': './assets/en/template/TEMPLATE_FLEET_AMMO.png', 'jp': './assets/jp/template/TEMPLATE_FLEET_AMMO.png', 'tw': './assets/tw/template/TEMPLATE_FLEET_AMMO.png'}) TEMPLATE_FLEET_AMMO = Template(file={'cn': './assets/cn/template/TEMPLATE_FLEET_AMMO.png', 'en': './assets/en/template/TEMPLATE_FLEET_AMMO.png', 'jp': './assets/jp/template/TEMPLATE_FLEET_AMMO.png', 'tw': './assets/tw/template/TEMPLATE_FLEET_AMMO.png'})
TEMPLATE_FORMATION_1 = Template(file={'cn': './assets/cn/template/TEMPLATE_FORMATION_1.png', 'en': './assets/en/template/TEMPLATE_FORMATION_1.png', 'jp': './assets/jp/template/TEMPLATE_FORMATION_1.png', 'tw': './assets/tw/template/TEMPLATE_FORMATION_1.png'}) TEMPLATE_FORMATION_1 = Template(file={'cn': './assets/cn/template/TEMPLATE_FORMATION_1.png', 'en': './assets/en/template/TEMPLATE_FORMATION_1.png', 'jp': './assets/jp/template/TEMPLATE_FORMATION_1.png', 'tw': './assets/tw/template/TEMPLATE_FORMATION_1.png'})
TEMPLATE_FORMATION_2 = Template(file={'cn': './assets/cn/template/TEMPLATE_FORMATION_2.png', 'en': './assets/en/template/TEMPLATE_FORMATION_2.png', 'jp': './assets/jp/template/TEMPLATE_FORMATION_2.png', 'tw': './assets/tw/template/TEMPLATE_FORMATION_2.png'}) TEMPLATE_FORMATION_2 = Template(file={'cn': './assets/cn/template/TEMPLATE_FORMATION_2.png', 'en': './assets/en/template/TEMPLATE_FORMATION_2.png', 'jp': './assets/jp/template/TEMPLATE_FORMATION_2.png', 'tw': './assets/tw/template/TEMPLATE_FORMATION_2.png'})