mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-04-01 21:56:20 +08:00
Opt: Relaxed conditions for ship changes
This commit is contained in:
@@ -708,6 +708,7 @@ class GemsFarming(CampaignRun, GemsEquipmentHandler, Retirement):
|
||||
total (int):
|
||||
"""
|
||||
self.config.STOP_IF_REACH_LV32 = self.change_flagship
|
||||
ship_change_attempted = False
|
||||
while 1:
|
||||
self._trigger_lv32 = False
|
||||
is_limit = self.config.StopCondition_RunCount
|
||||
@@ -722,20 +723,39 @@ class GemsFarming(CampaignRun, GemsEquipmentHandler, Retirement):
|
||||
else:
|
||||
raise e
|
||||
except RequestHumanTakeover as e:
|
||||
if (not e.args or e.args[0] != 'Hard not satisfied'
|
||||
or not (self.change_flagship or self.change_vanguard)):
|
||||
raise
|
||||
|
||||
if ship_change_attempted:
|
||||
logger.critical("Hard mode requirements still not satisfied after ship change")
|
||||
raise
|
||||
|
||||
attack_fleet = ('FLEET_2' if self.config.Fleet_FleetOrder == 'fleet1_standby_fleet2_all'
|
||||
else 'FLEET_1')
|
||||
if e.args[1:] != (attack_fleet, ):
|
||||
logger.critical("Fleet not meeting requirements is not (or not only) the attack fleet, " \
|
||||
"please check ALAS settings and in-game fleet preparation")
|
||||
raise
|
||||
|
||||
logger.warning('Hard mode requirements not satisfied, attempting ship change once')
|
||||
try:
|
||||
if e.args[0] == 'Hard not satisfied' and self.change_flagship and self.change_vanguard:
|
||||
self.hard_mode_override()
|
||||
self.hard_mode_override()
|
||||
if self.change_flagship:
|
||||
self.flagship_change()
|
||||
if self.change_vanguard:
|
||||
self.vanguard_change()
|
||||
else:
|
||||
raise RequestHumanTakeover
|
||||
except RequestHumanTakeover as e:
|
||||
raise RequestHumanTakeover
|
||||
except Exception as e:
|
||||
ship_change_attempted = True
|
||||
continue
|
||||
except RequestHumanTakeover:
|
||||
logger.warning("Failed to change ship")
|
||||
raise
|
||||
except Exception:
|
||||
from module.exception import GameStuckError
|
||||
raise GameStuckError
|
||||
|
||||
# End
|
||||
ship_change_attempted = False
|
||||
|
||||
if self._trigger_lv32 or self._trigger_emotion:
|
||||
success = True
|
||||
self.hard_mode_override()
|
||||
|
||||
@@ -122,12 +122,13 @@ class FleetOperator:
|
||||
# logger.attr('Light_orange_line', lines)
|
||||
return lines > 0
|
||||
|
||||
def raise_hard_not_satisfied(self):
|
||||
if self.is_hard_satisfied() is False:
|
||||
stage = self.main.config.Campaign_Name
|
||||
logger.critical(f'Stage "{stage}" is a hard mode, '
|
||||
f'please prepare your fleet "{str(self)}" in game before running Alas')
|
||||
raise RequestHumanTakeover('Hard not satisfied', str(self))
|
||||
# Remove this function, centralized validation and unified error raising
|
||||
# def raise_hard_not_satisfied(self):
|
||||
# if self.is_hard_satisfied() is False:
|
||||
# stage = self.main.config.Campaign_Name
|
||||
# logger.critical(f'Stage "{stage}" is a hard mode, '
|
||||
# f'please prepare your fleet "{str(self)}" in game before running Alas')
|
||||
# raise RequestHumanTakeover('Hard not satisfied', str(self))
|
||||
|
||||
def clear(self, skip_first_screenshot=True):
|
||||
"""
|
||||
@@ -337,18 +338,27 @@ class FleetPreparation(InfoHandler):
|
||||
h1, h2, h3 = fleet_1.is_hard_satisfied(), fleet_2.is_hard_satisfied(), submarine.is_hard_satisfied()
|
||||
logger.info(f'Hard satisfied: Fleet_1: {h1}, Fleet_2: {h2}, Submarine: {h3}')
|
||||
if self.config.SERVER in ['cn', 'en', 'jp']:
|
||||
if self.config.Fleet_Fleet1:
|
||||
fleet_1.raise_hard_not_satisfied()
|
||||
if self.config.Fleet_Fleet2:
|
||||
fleet_2.raise_hard_not_satisfied()
|
||||
if self.config.Submarine_Fleet:
|
||||
if self.config.Submarine_AutoRecommend and h3 is False:
|
||||
logger.info('AutoRecommend enabled, click recommend to form submarine fleet')
|
||||
unsatisfied = []
|
||||
if self.config.Fleet_Fleet1 and h1 is False:
|
||||
unsatisfied.append(str(fleet_1))
|
||||
if self.config.Fleet_Fleet2 and h2 is False:
|
||||
unsatisfied.append(str(fleet_2))
|
||||
if self.config.Submarine_Fleet and h3 is False:
|
||||
auto_recommend = self.config.Submarine_AutoRecommend
|
||||
logger.attr('Submarine AutoRecommend', auto_recommend)
|
||||
if auto_recommend:
|
||||
logger.info('Form submarine fleet via Recommend')
|
||||
submarine.recommend()
|
||||
self.device.screenshot()
|
||||
h3 = submarine.is_hard_satisfied()
|
||||
logger.info(f'Hard satisfied after recommend: Submarine: {h3}')
|
||||
submarine.raise_hard_not_satisfied()
|
||||
logger.info(f'Hard satisfied: Fleet_1: {h1}, Fleet_2: {h2}, Submarine: {h3}')
|
||||
if h3 is False:
|
||||
unsatisfied.append(str(submarine))
|
||||
if unsatisfied:
|
||||
stage = self.config.Campaign_Name
|
||||
logger.critical(f'Stage "{stage}" is a hard mode, '
|
||||
f'please prepare your fleet(s): {", ".join(unsatisfied)} in game before running Alas')
|
||||
raise RequestHumanTakeover('Hard not satisfied', *unsatisfied)
|
||||
|
||||
# Skip fleet preparation in hard mode
|
||||
self.map_is_hard_mode = h1 or h2 or h3
|
||||
|
||||
Reference in New Issue
Block a user