1
0
mirror of https://github.com/sui-feng-cb/AzurLaneAutoScript1.git synced 2026-07-06 21:15:07 +08:00

Refactor: separate submarine_mode for clearer semantics

This commit is contained in:
positnuec
2026-07-02 17:47:24 +08:00
parent d9a9b784af
commit bb8a6d6044
19 changed files with 364 additions and 239 deletions

View File

@@ -343,8 +343,8 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
self.submarine_call_reset()
submarine_mode = 'do_not_use'
if self.config.Submarine_Fleet:
submarine_mode = self.config.Submarine_Mode
force_call = battle[0] == battle[1] - 1 if battle is not None else False
submarine_mode = self.config.Submarine_CallMode
is_boss = battle[0] == battle[1] - 1 if battle is not None else False
self.combat_auto_reset()
self.combat_manual_reset()
self.device.stuck_record_clear()
@@ -358,7 +358,7 @@ class AutoSearchCombat(MapOperation, Combat, CampaignStatus):
exp_confirm_timer = Timer(1, count=2)
for _ in self.loop():
if self.handle_submarine_call(submarine_mode, call=force_call):
if self.handle_submarine_call(call_mode=submarine_mode, is_boss=is_boss):
continue
if self.handle_combat_auto(auto):
continue

View File

@@ -348,11 +348,12 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
return False
def combat_execute(self, auto='combat_auto', submarine='do_not_use', drop=None):
def combat_execute(self, auto='combat_auto', submarine='do_not_use', is_boss=False, drop=None):
"""
Args:
auto (str): ['combat_auto', 'combat_manual', 'stand_still_in_the_middle', 'hide_in_bottom_left']
submarine (str): ['do_not_use', 'hunt_only', 'every_combat']
submarine (str): do_not_use, boss_only, every_combat
is_boss (bool): True on BOSS battle
drop (DropImage):
"""
logger.info('Combat execute')
@@ -379,7 +380,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
if auto != 'combat_auto' and self.auto_mode_checked and self.is_combat_executing():
if self.handle_combat_weapon_release():
continue
if self.handle_submarine_call(submarine):
if self.handle_submarine_call(call_mode=submarine, is_boss=is_boss):
continue
# bunch of popup handlers
if self.handle_popup_confirm('COMBAT_EXECUTE'):
@@ -629,7 +630,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
if self.handle_in_map_with_enemy_searching(drop=drop):
break
def combat(self, balance_hp=None, emotion_reduce=None, auto_mode=None, submarine_mode=None,
def combat(self, balance_hp=None, emotion_reduce=None, auto_mode=None, submarine_mode=None, is_boss=False,
save_get_items=None, expected_end=None, fleet_index=1):
"""
Execute a combat.
@@ -639,7 +640,8 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
balance_hp (bool):
emotion_reduce (bool):
auto_mode (str): combat_auto, combat_manual, stand_still_in_the_middle, hide_in_bottom_left
submarine_mode (str): do_not_use, hunt_only, every_combat
submarine_mode (str): do_not_use, boss_only, every_combat
is_boss (bool): True on BOSS battle
save_get_items (bool, DropImage):
expected_end (str, callable):
fleet_index (int): 1 or 2
@@ -651,7 +653,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
if submarine_mode is None:
submarine_mode = 'do_not_use'
if self.config.Submarine_Fleet:
submarine_mode = self.config.Submarine_Mode
submarine_mode = self.config.Submarine_CallMode
self.battle_status_click_interval = 7 if save_get_items else 0
# if not hasattr(self, 'emotion'):
@@ -667,7 +669,7 @@ class Combat(Level, HPBalancer, Retirement, SubmarineCall, CombatAuto, CombatMan
self.combat_preparation(
balance_hp=balance_hp, emotion_reduce=emotion_reduce, auto=auto_mode, fleet_index=fleet_index)
self.combat_execute(
auto=auto_mode, submarine=submarine_mode, drop=drop)
auto=auto_mode, submarine=submarine_mode, drop=drop, is_boss=is_boss)
self.combat_status(
drop=drop, expected_end=expected_end)
# self.handle_map_after_combat_story()

View File

@@ -16,19 +16,21 @@ class SubmarineCall(ModuleBase):
self.submarine_call_timer.reset()
self.submarine_call_flag = False
def handle_submarine_call(self, submarine='do_not_use', call=False):
def handle_submarine_call(self, call_mode='do_not_use', is_boss=False):
"""
Args:
call_mode (str): do_not_use, boss_only, every_combat
is_boss (bool): True on BOSS battle
Returns:
str: If call.
bool: If clicked submarine call button.
"""
if self.submarine_call_flag:
return False
if call and submarine == 'boss_only':
pass
else:
if submarine in ['do_not_use', 'hunt_only', 'boss_only', 'hunt_and_boss']:
self.submarine_call_flag = True
return False
if call_mode == 'do_not_use' or (call_mode == 'boss_only' and not is_boss):
self.submarine_call_flag = True
return False
if self.submarine_call_timer.reached():
logger.info('Submarine call timer reached')
self.submarine_call_flag = True