mirror of
https://github.com/LmeSzinc/AzurLaneAutoScript.git
synced 2025-01-08 13:07:33 +08:00
Fix: W15 optimization (#3660)
* Fix: force battle function choice for 15-1/15-2 when clear all * Add: battle strategy when missing support fleet in W15 * Opt: open strategy once when checking mob move * Opt: reuse strategy_get_mob_move_remain()
This commit is contained in:
parent
250cf4e1a2
commit
41075b4a52
@ -65,14 +65,25 @@ class Config(ConfigBase):
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
|
||||
def battle_function(self):
|
||||
if self.config.MAP_CLEAR_ALL_THIS_TIME \
|
||||
and self.battle_count == 0 and not self.map_is_clear_mode:
|
||||
func = self.FUNCTION_NAME_BASE + str(self.battle_count)
|
||||
logger.info(f'Using function: {func}')
|
||||
func = self.__getattribute__(func)
|
||||
result = func()
|
||||
return result
|
||||
|
||||
return super().battle_function()
|
||||
|
||||
def battle_0(self):
|
||||
if not self.map_is_clear_mode:
|
||||
if not self.map_is_clear_mode and self.map_has_mob_move:
|
||||
self.mob_move(B3, C3)
|
||||
self.clear_chosen_enemy(B1)
|
||||
return True
|
||||
else:
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=1):
|
||||
return True
|
||||
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=1):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
|
@ -66,15 +66,26 @@ class Config(ConfigBase):
|
||||
class Campaign(CampaignBase):
|
||||
MAP = MAP
|
||||
|
||||
def battle_function(self):
|
||||
if self.config.MAP_CLEAR_ALL_THIS_TIME \
|
||||
and self.battle_count == 0 and not self.map_is_clear_mode:
|
||||
func = self.FUNCTION_NAME_BASE + str(self.battle_count)
|
||||
logger.info(f'Using function: {func}')
|
||||
func = self.__getattribute__(func)
|
||||
result = func()
|
||||
return result
|
||||
|
||||
return super().battle_function()
|
||||
|
||||
def battle_0(self):
|
||||
if not self.map_is_clear_mode:
|
||||
if not self.map_is_clear_mode and self.map_has_mob_move:
|
||||
self.mob_move(I6, I7)
|
||||
self.mob_move(I7, H7)
|
||||
self.clear_chosen_enemy(G7)
|
||||
return True
|
||||
else:
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=1):
|
||||
return True
|
||||
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=1):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
|
@ -81,13 +81,13 @@ class Campaign(CampaignBase):
|
||||
return super().battle_function()
|
||||
|
||||
def battle_0(self):
|
||||
if not self.map_is_clear_mode:
|
||||
if not self.map_is_clear_mode and self.map_has_mob_move:
|
||||
self.mob_move(B3, B4)
|
||||
self.clear_chosen_enemy(A1)
|
||||
return True
|
||||
else:
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=1):
|
||||
return True
|
||||
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=1):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
|
@ -90,28 +90,27 @@ class Campaign(CampaignBase):
|
||||
return super().battle_function()
|
||||
|
||||
def battle_0(self):
|
||||
if not self.map_is_clear_mode:
|
||||
self.clear_chosen_enemy(A1)
|
||||
if not self.map_is_clear_mode and self.map_has_mob_move:
|
||||
self.mob_move(J8, J7)
|
||||
self.clear_chosen_enemy(K9)
|
||||
return True
|
||||
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=0):
|
||||
return True
|
||||
else:
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=0):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_1(self):
|
||||
if not self.map_is_clear_mode:
|
||||
self.mob_move(J8, J7)
|
||||
self.clear_chosen_enemy(K9)
|
||||
self.clear_chosen_enemy(A1)
|
||||
return True
|
||||
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=0):
|
||||
return True
|
||||
else:
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=0):
|
||||
return True
|
||||
|
||||
return self.battle_default()
|
||||
|
||||
def battle_2(self):
|
||||
self.pick_up_ammo()
|
||||
if self.clear_filter_enemy(self.ENEMY_FILTER, preserve=0):
|
||||
return True
|
||||
|
||||
@ -123,6 +122,7 @@ class Campaign(CampaignBase):
|
||||
self.fleet_1.switch_to()
|
||||
return True
|
||||
else:
|
||||
self.pick_up_ammo()
|
||||
self.clear_chosen_enemy(H5, expected='siren')
|
||||
return True
|
||||
|
||||
|
@ -36,6 +36,17 @@ class CampaignBase(CampaignBase_):
|
||||
_ = ASSETS.ui_mask
|
||||
ASSETS.ui_mask = MASK_MAP_UI_W15.image
|
||||
|
||||
map_has_mob_move = False
|
||||
|
||||
def strategy_set_execute(self, formation_index=None, sub_view=None, sub_hunt=None):
|
||||
super().strategy_set_execute(
|
||||
formation_index=formation_index,
|
||||
sub_view=sub_view,
|
||||
sub_hunt=sub_hunt,
|
||||
)
|
||||
self.map_has_mob_move = (self.strategy_get_mob_move_remain() > 0)
|
||||
logger.attr("Map has mob move", self.map_has_mob_move)
|
||||
|
||||
def _map_swipe(self, vector, box=(239, 159, 1175, 628)):
|
||||
# Left border to 239, avoid swiping on support fleet
|
||||
return super()._map_swipe(vector, box=box)
|
||||
|
@ -20,6 +20,8 @@ submarine_view = Switch('Submarine_view', offset=(100, 200))
|
||||
submarine_view.add_status('on', check_button=SUBMARINE_VIEW_ON)
|
||||
submarine_view.add_status('off', check_button=SUBMARINE_VIEW_OFF)
|
||||
|
||||
MOB_MOVE_OFFSET = (120, 120)
|
||||
|
||||
|
||||
class StrategyHandler(InfoHandler):
|
||||
fleet_1_formation_fixed = False
|
||||
@ -215,9 +217,9 @@ class StrategyHandler(InfoHandler):
|
||||
in: STRATEGY_OPENED
|
||||
out: STRATEGY_OPENED
|
||||
"""
|
||||
if self.appear(MOB_MOVE_2, offset=(120, 120)):
|
||||
if self.appear(MOB_MOVE_2, offset=MOB_MOVE_OFFSET):
|
||||
return 2
|
||||
elif self.appear(MOB_MOVE_1, offset=(120, 120)):
|
||||
elif self.appear(MOB_MOVE_1, offset=MOB_MOVE_OFFSET):
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
@ -238,9 +240,9 @@ class StrategyHandler(InfoHandler):
|
||||
if self.appear(MOB_MOVE_CANCEL, offset=(20, 20)):
|
||||
break
|
||||
|
||||
if self.appear_then_click(MOB_MOVE_1, offset=(120, 120), interval=5):
|
||||
if self.appear_then_click(MOB_MOVE_1, offset=MOB_MOVE_OFFSET, interval=5):
|
||||
continue
|
||||
if self.appear_then_click(MOB_MOVE_2, offset=(120, 120), interval=5):
|
||||
if self.appear_then_click(MOB_MOVE_2, offset=MOB_MOVE_OFFSET, interval=5):
|
||||
continue
|
||||
|
||||
def strategy_mob_move_cancel(self, skip_first_screenshot=True):
|
||||
@ -256,8 +258,8 @@ class StrategyHandler(InfoHandler):
|
||||
else:
|
||||
self.device.screenshot()
|
||||
|
||||
if self.appear(MOB_MOVE_1, offset=(120, 120)) \
|
||||
or self.appear(MOB_MOVE_2, offset=(120, 120)):
|
||||
if self.appear(MOB_MOVE_1, offset=MOB_MOVE_OFFSET) \
|
||||
or self.appear(MOB_MOVE_2, offset=MOB_MOVE_OFFSET):
|
||||
break
|
||||
|
||||
if self.appear_then_click(MOB_MOVE_CANCEL, offset=(20, 20), interval=5):
|
||||
|
Loading…
Reference in New Issue
Block a user