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