mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-18 06:51:28 +08:00
Refactor: Gems farming configs
- Opt: Avoid clicking AUTO_SEARCH_MAP_OPTION_OFF after ignore low emotion warn - Opt: Skip map cat attack in auto search
This commit is contained in:
@@ -4,10 +4,10 @@ from module.combat.level import LevelOcr
|
||||
from module.equipment.assets import *
|
||||
from module.equipment.equipment_change import EquipmentChange
|
||||
from module.equipment.fleet_equipment import OCR_FLEET_INDEX
|
||||
from module.logger import logger
|
||||
from module.map.assets import FLEET_PREPARATION, MAP_PREPARATION
|
||||
from module.ocr.ocr import Digit
|
||||
from module.retire.dock import *
|
||||
from module.retire.dock import Dock
|
||||
from module.ui.page import page_fleet
|
||||
|
||||
SIM_VALUE = 0.95
|
||||
@@ -16,12 +16,12 @@ SIM_VALUE = 0.95
|
||||
class GemsCampaignOverride(CampaignBase):
|
||||
|
||||
def handle_combat_low_emotion(self):
|
||||
'''
|
||||
"""
|
||||
Overwrite info_handler.handle_combat_low_emotion()
|
||||
If GEMS_LOW_EMOTION_WITHDRAW is True, withdraw combat and change flag ship
|
||||
'''
|
||||
if self.config.GEMS_LOW_EMOTION_WITHDRAW:
|
||||
if not self.config.IGNORE_LOW_EMOTION_WARN:
|
||||
"""
|
||||
if self.config.GemsFarming_LowEmotionRetreat:
|
||||
if not self.config.Emotion_IgnoreLowEmotionWarn:
|
||||
return False
|
||||
if self.handle_popup_cancel('IGNORE_LOW_EMOTION'):
|
||||
self.config.GEMS_EMOTION_TRIGGRED = True
|
||||
@@ -37,7 +37,8 @@ class GemsCampaignOverride(CampaignBase):
|
||||
self.withdraw()
|
||||
break
|
||||
|
||||
if self.appear(FLEET_PREPARATION, offset=(20, 20), interval=2) or self.appear(MAP_PREPARATION, offset=(20, 20), interval=2):
|
||||
if self.appear(FLEET_PREPARATION, offset=(20, 20), interval=2) \
|
||||
or self.appear(MAP_PREPARATION, offset=(20, 20), interval=2):
|
||||
self.enter_map_cancel()
|
||||
break
|
||||
return False
|
||||
@@ -45,7 +46,7 @@ class GemsCampaignOverride(CampaignBase):
|
||||
return super().handle_combat_low_emotion()
|
||||
|
||||
|
||||
class GemsFarming(CampaignRun, EquipmentChange):
|
||||
class GemsFarming(CampaignRun, Dock, EquipmentChange):
|
||||
|
||||
def load_campaign(self, name, folder='campaign_main'):
|
||||
super().load_campaign(name, folder)
|
||||
@@ -56,11 +57,11 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
self.campaign = GemsCampaign(device=self.device, config=self.config)
|
||||
|
||||
def _fleet_detail_enter(self):
|
||||
'''
|
||||
"""
|
||||
Enter GEMS_FLEET_1 page
|
||||
'''
|
||||
"""
|
||||
self.ui_ensure(page_fleet)
|
||||
self.ui_ensure_index(self.config.GEMS_FLEET_1, letter=OCR_FLEET_INDEX,
|
||||
self.ui_ensure_index(self.config.Fleet_Fleet1, letter=OCR_FLEET_INDEX,
|
||||
next_button=FLEET_NEXT, prev_button=FLEET_PREV, skip_first_screenshot=True)
|
||||
|
||||
def _ship_detail_enter(self, button):
|
||||
@@ -68,17 +69,17 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
self.equip_enter(button)
|
||||
|
||||
def flagship_change(self):
|
||||
'''
|
||||
"""
|
||||
Change flagship and flagship's equipment
|
||||
If config.COMMON_CV_NAME == 'any', only change auxiliary equipment
|
||||
'''
|
||||
If config.GemsFarming_CommonCV == 'any', only change auxiliary equipment
|
||||
"""
|
||||
|
||||
if self.config.COMMON_CV_NAME == 'any':
|
||||
if self.config.GemsFarming_CommonCV == 'any':
|
||||
index_list = range(3, 5)
|
||||
else:
|
||||
index_list = range(0, 5)
|
||||
logger.hr('CHANGING FLAGSHIP.')
|
||||
if self.config.GEMS_FLAG_SHIP_EQUIP_CHANGE:
|
||||
if self.config.GemsFarming_FlagshipEquipChange:
|
||||
logger.info('Record flagship equipment.')
|
||||
self._ship_detail_enter(FLEET_ENTER_FLAGSHIP)
|
||||
self.record_equipment(index_list=index_list)
|
||||
@@ -88,7 +89,7 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
|
||||
self.flagship_change_execute()
|
||||
|
||||
if self.config.GEMS_FLAG_SHIP_EQUIP_CHANGE:
|
||||
if self.config.GemsFarming_FlagshipEquipChange:
|
||||
logger.info('Record flagship equipment.')
|
||||
self._ship_detail_enter(FLEET_ENTER_FLAGSHIP)
|
||||
self._equip_take_off_one()
|
||||
@@ -96,11 +97,11 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
self.equipment_take_on(index_list=index_list)
|
||||
|
||||
def vanguard_change(self):
|
||||
'''
|
||||
"""
|
||||
Change vanguard and vanguard's equipment
|
||||
'''
|
||||
"""
|
||||
logger.hr('CHANGING VANGUARD.')
|
||||
if self.config.GEMS_VANGUARD_SHIP_EQUIP_CHANGE:
|
||||
if self.config.GemsFarming_VanguardEquipChange:
|
||||
logger.info('Record vanguard equipment.')
|
||||
self._ship_detail_enter(FLEET_ENTER)
|
||||
self.record_equipment()
|
||||
@@ -110,7 +111,7 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
|
||||
self.vanguard_change_execute()
|
||||
|
||||
if self.config.GEMS_VANGUARD_SHIP_EQUIP_CHANGE:
|
||||
if self.config.GemsFarming_VanguardEquipChange:
|
||||
logger.info('Equip vanguard equipment.')
|
||||
self._ship_detail_enter(FLEET_ENTER)
|
||||
self._equip_take_off_one()
|
||||
@@ -125,8 +126,8 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
|
||||
def get_common_rarity_cv(self):
|
||||
"""
|
||||
Get a common rarity cv by config.COMMON_CV_NAME
|
||||
If config.COMMON_CV_NAME == 'any', return a common lv1 cv
|
||||
Get a common rarity cv by config.GemsFarming_CommonCV
|
||||
If config.GemsFarming_CommonCV == 'any', return a common lv1 cv
|
||||
Returns:
|
||||
Button:
|
||||
"""
|
||||
@@ -135,7 +136,7 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
card_grids = CARD_GRIDS
|
||||
logger.hr('FINDING FLAGSHIP')
|
||||
|
||||
if self.config.COMMON_CV_NAME == 'any':
|
||||
if self.config.GemsFarming_CommonCV == 'any':
|
||||
logger.info('')
|
||||
|
||||
self.dock_sort_method_dsc_set(False)
|
||||
@@ -150,7 +151,7 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
return None
|
||||
else:
|
||||
template = globals()[
|
||||
f'TEMPLATE_{self.config.COMMON_CV_NAME.upper()}']
|
||||
f'TEMPLATE_{self.config.GemsFarming_CommonCV.upper()}']
|
||||
|
||||
self.dock_sort_method_dsc_set()
|
||||
|
||||
@@ -160,7 +161,7 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
for button, level in zip(card_grids.buttons, list_level):
|
||||
if level == 1 and template.match(self.device.image.crop(button.area), similarity=SIM_VALUE):
|
||||
return button
|
||||
|
||||
|
||||
logger.info('No specific CV was found, try reversed order.')
|
||||
self.dock_sort_method_dsc_set(False)
|
||||
|
||||
@@ -258,47 +259,30 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
|
||||
def triggered_stop_condition(self, oil_check=True):
|
||||
# Lv32 limit
|
||||
if self.config.STOP_IF_REACH_LV32 and self.campaign.config.LV32_TRIGGERED:
|
||||
if self.config.GemsFarming_FlagshipChange and self.campaign.config.LV32_TRIGGERED:
|
||||
self._trigger_lv32 = True
|
||||
logger.hr('TRIGGERED LV32 LIMIT')
|
||||
return True
|
||||
|
||||
if self.config.ENABLE_AUTO_SEARCH and self.campaign.config.GEMS_EMOTION_TRIGGRED:
|
||||
if self.config.Campaign_UseAutoSearch and self.campaign.config.GEMS_EMOTION_TRIGGRED:
|
||||
self._trigger_emotion = True
|
||||
logger.hr('TRIGGERED EMOTION LIMIT')
|
||||
return True
|
||||
|
||||
return super().triggered_stop_condition(oil_check=oil_check)
|
||||
|
||||
def run(self, name, folder='campaign_main', total=0):
|
||||
name = name.lower()
|
||||
if not name[0].isdigit():
|
||||
folder = self.config.EVENT_NAME
|
||||
else:
|
||||
name = 'campaign_' + name.replace('-', '_')
|
||||
def run(self, name, folder='campaign_main', mode='normal', total=0):
|
||||
"""
|
||||
Args:
|
||||
name (str): Name of .py file.
|
||||
folder (str): Name of the file folder under campaign.
|
||||
mode (str): `normal` or `hard`
|
||||
total (int):
|
||||
"""
|
||||
self.config.STOP_IF_REACH_LV32 = self.config.GemsFarming_FlagshipChange
|
||||
self.config.RETIRE_KEEP_COMMON_CV = True
|
||||
|
||||
while 1:
|
||||
# Backup config file
|
||||
# while cover ENABLE_AUTO_SEARCH
|
||||
backup = self.config.cover(
|
||||
STOP_IF_REACH_LV32=True,
|
||||
FLEET_1=self.config.GEMS_FLEET_1,
|
||||
FLEET_2=self.config.GEMS_FLEET_2,
|
||||
FLEET_BOSS=1,
|
||||
SUBMARINE=0,
|
||||
FLEET_1_FORMATION=1,
|
||||
FLEET_2_FORMATION=1,
|
||||
FLEET_1_AUTO_MODE='combat_auto',
|
||||
FLEET_2_AUTO_MODE='combat_auto',
|
||||
ENABLE_MAP_FLEET_LOCK=True,
|
||||
ENABLE_2X_BOOK=False,
|
||||
STOP_IF_MAP_REACH='no',
|
||||
ENABLE_EMOTION_REDUCE=False,
|
||||
IGNORE_LOW_EMOTION_WARN=True,
|
||||
AUTO_SEARCH_SETTING='fleet1_all_fleet2_standby',
|
||||
ENABLE_AUTO_SEARCH=self.config.GEMS_ENABLE_AUTO_SEARCH,
|
||||
RETIRE_KEEP_COMMON_CV=True,
|
||||
)
|
||||
self._trigger_lv32 = False
|
||||
|
||||
super().run(name=name, folder=folder, total=total)
|
||||
@@ -307,7 +291,7 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
if self._trigger_lv32 or self._trigger_emotion:
|
||||
self.flagship_change()
|
||||
|
||||
if self.config.GEMS_LOW_EMOTION_WITHDRAW:
|
||||
if self.config.GemsFarming_LowEmotionRetreat:
|
||||
self.vanguard_change()
|
||||
|
||||
self._trigger_lv32 = False
|
||||
@@ -316,5 +300,4 @@ class GemsFarming(CampaignRun, EquipmentChange):
|
||||
self.campaign.config.GEMS_EMOTION_TRIGGRED = False
|
||||
continue
|
||||
else:
|
||||
backup.recover()
|
||||
break
|
||||
|
||||
@@ -70,19 +70,23 @@ class CampaignRun(UI):
|
||||
if self.run_limit and self.config.StopCondition_RunCount <= 0:
|
||||
logger.hr('Triggered stop condition: Run count')
|
||||
self.config.StopCondition_RunCount = 0
|
||||
self.config.Scheduler_Enable = False
|
||||
return True
|
||||
# Lv120 limit
|
||||
if self.config.StopCondition_ReachLevel120 and self.campaign.config.LV120_TRIGGERED:
|
||||
logger.hr('Triggered stop condition: Reach level 120')
|
||||
self.config.Scheduler_Enable = False
|
||||
return True
|
||||
# Oil limit
|
||||
if oil_check and self.config.StopCondition_OilLimit:
|
||||
if OCR_OIL.ocr(self.device.image) < self.config.StopCondition_OilLimit:
|
||||
logger.hr('Triggered stop condition: Oil limit')
|
||||
self.config.Scheduler_Enable = False
|
||||
return True
|
||||
# If Get a New Ship
|
||||
if self.config.StopCondition_GetNewShip and self.campaign.config.GET_SHIP_TRIGGERED:
|
||||
logger.hr('Triggered stop condition: Get new ship')
|
||||
self.config.Scheduler_Enable = False
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -120,6 +124,8 @@ class CampaignRun(UI):
|
||||
Returns:
|
||||
str, str: name, folder
|
||||
"""
|
||||
if name[0].isdigit():
|
||||
name = 'campaign_' + name.lower().replace('-', '_')
|
||||
if folder == 'event_20201126_cn' and name == 'vsp':
|
||||
name = 'sp'
|
||||
if folder == 'event_20210723_cn' and name == 'vsp':
|
||||
@@ -171,7 +177,6 @@ class CampaignRun(UI):
|
||||
# End
|
||||
if self.triggered_stop_condition(oil_check=not self.campaign.is_in_auto_search_menu()):
|
||||
self.campaign.ensure_auto_search_exit()
|
||||
self.config.Scheduler_Enable = False
|
||||
break
|
||||
|
||||
# Run
|
||||
|
||||
Reference in New Issue
Block a user