diff --git a/module/campaign/campaign_base.py b/module/campaign/campaign_base.py index a49ba3595..2cff764fa 100644 --- a/module/campaign/campaign_base.py +++ b/module/campaign/campaign_base.py @@ -30,6 +30,8 @@ class CampaignBase(Map): def execute_a_battle(self): logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2) logger.info('Running with poor map data.') + if self.fleet_2_break_siren_caught(): + return True self.clear_all_mystery() if self.battle_count >= 3: @@ -50,6 +52,8 @@ class CampaignBase(Map): def execute_a_battle(self): logger.hr(f'{self.FUNCTION_NAME_BASE}{self.battle_count}', level=2) logger.info('Using function: clear_all') + if self.fleet_2_break_siren_caught(): + return True self.clear_all_mystery() if self.battle_count >= 3: diff --git a/module/map/fleet.py b/module/map/fleet.py index 9f3cd3a00..f3d21a8aa 100644 --- a/module/map/fleet.py +++ b/module/map/fleet.py @@ -158,7 +158,9 @@ class Fleet(Camera, MapOperation, AmbushHandler): raise MapWalkError('walk_out_of_step') # Arrive - if self.is_in_map() and (grid.predict_fleet() or grid.predict_current_fleet()): + if self.is_in_map() and \ + (grid.predict_fleet() or + (walk_timeout.reached() and grid.predict_current_fleet())): if not arrive_timer.started(): logger.info(f'Arrive {location2node(location)}') arrive_timer.start() diff --git a/module/map/grid_info.py b/module/map/grid_info.py index 3a00d7776..5274c7013 100644 --- a/module/map/grid_info.py +++ b/module/map/grid_info.py @@ -47,6 +47,7 @@ class GridInfo: is_cleared = False is_ambush_save = False + is_caught_by_siren = False cost = 9999 connection = None weight = 1 @@ -90,6 +91,7 @@ class GridInfo: dic = { 'FL': 'is_current_fleet', 'Fl': 'is_fleet', + 'Fc': 'is_caught_by_siren', 'MY': 'is_mystery', 'AM': 'is_ammo', '==': 'is_cleared' @@ -178,6 +180,8 @@ class GridInfo: self.is_fleet = info.is_fleet if info.is_current_fleet: self.is_current_fleet = True + if info.is_caught_by_siren: + self.is_caught_by_siren = True return False def wipe_out(self): diff --git a/module/map/grid_predictor.py b/module/map/grid_predictor.py index ab50d10ad..4a0b21a4f 100644 --- a/module/map/grid_predictor.py +++ b/module/map/grid_predictor.py @@ -68,7 +68,8 @@ class GridPredictor: if not self.is_enemy and not self.is_mystery: if self.predict_dynamic_red_border(): self.enemy_type = 'Siren_unknown' - # self.caught_by_siren = self.predict_siren_caught() + if self.config.MAP_HAS_MOVABLE_ENEMY: + self.is_caught_by_siren = self.predict_siren_caught() if self.enemy_type: self.is_enemy = True diff --git a/module/map/map.py b/module/map/map.py index 97132f615..951ebe900 100644 --- a/module/map/map.py +++ b/module/map/map.py @@ -364,3 +364,25 @@ class Map(Fleet): self.fleet_1.clear_roadblocks(roadblocks) self.fleet_1.clear_all_mystery() return True + + def fleet_2_break_siren_caught(self): + if not self.config.MAP_HAS_SIREN or not self.config.MAP_HAS_MOVABLE_ENEMY: + return False + if not self.map.select(is_caught_by_siren=True): + logger.info('No fleet caught by siren.') + return False + if not self.fleet_2_location or not self.map[self.fleet_2_location].is_caught_by_siren: + logger.warning('Appear caught by siren, but not fleet_2.') + for grid in self.map: + grid.is_caught_by_siren = False + return False + + logger.info(f'Break siren caught, fleet_2: {self.fleet_2_location}') + self.fleet_2.switch_to() + self.ensure_edge_insight(reverse=True) + self.clear_chosen_enemy(self.map[self.fleet_2_location]) + self.fleet_1.switch_to() + for grid in self.map: + grid.is_caught_by_siren = False + return True + diff --git a/module/map/map_base.py b/module/map/map_base.py index 47f10de98..af80c57b3 100644 --- a/module/map/map_base.py +++ b/module/map/map_base.py @@ -253,6 +253,8 @@ class CampaignMap: MAP_7_2._find_path(node2location('H2')) [(2, 2), (3, 2), (4, 2), (5, 2), (6, 2), (6, 1), (7, 1)] # ['C3', 'D3', 'E3', 'F3', 'G3', 'G2', 'H2'] """ + if self[location].cost == 0: + return [location] if self[location].connection is None: return None res = [location]