diff --git a/modules/combat.py b/modules/combat.py index 55fb56c..2aea863 100644 --- a/modules/combat.py +++ b/modules/combat.py @@ -129,7 +129,7 @@ def combat_logic_wrapper(self): self.exit = 0 Logger.log_msg("Repeating map {}.".format(self.chapter_map)) Utils.touch_randomly(map_region) - continue + continue if self.exit > 2: self.stats.increment_combat_attempted() break @@ -181,7 +181,7 @@ def combat_logic_wrapper(self): if Utils.find("menu/button_confirm"): Logger.log_msg("Found commission info message.") Utils.touch_randomly(self.region["combat_com_confirm"]) - + Utils.script_sleep(1) Utils.menu_navigate("menu/button_battle") @@ -193,7 +193,7 @@ def reach_map(self): If the map isn't found, it navigates the map selection menu to get to the world where the specified map is located. Only works with standard maps up to worlds 13 and some event maps. Also checks if hard mode is enabled, and if it's legit to keep it so (event maps C and D). - If nothing is found even after menu navigation, it stops the bot workflow until the user moves to the right + If nothing is found even after menu navigation, it stops the bot workflow until the user moves to the right screen or the map asset is substituted with the right one. Returns: @@ -206,7 +206,7 @@ def reach_map(self): Utils.touch_randomly(self.region["menu_button_battle"]) Utils.wait_update_screen(2) - # correct map mode + # correct map mode if not self.chapter_map[0].isdigit(): letter = self.chapter_map[2] event_maps = ['A', 'B', 'S', 'C', 'D'] @@ -223,7 +223,7 @@ def reach_map(self): Logger.log_debug("Disabling hard mode.") Utils.touch_randomly(self.region['normal_mode_button']) Utils.wait_update_screen(1) - + map_region = Utils.find('maps/map_{}'.format(self.chapter_map), 0.99) if map_region != None: Logger.log_msg("Found specified map.") @@ -256,7 +256,7 @@ def reach_map(self): Utils.touch_randomly(self.region['map_nav_left']) Logger.log_debug("Swiping to the left") Utils.script_sleep() - + Utils.wait_update_screen() map_region = Utils.find('maps/map_{}'.format(self.chapter_map), 0.99) if map_region == None: @@ -342,7 +342,7 @@ def battle_handler(self, boss=False): Logger.log_msg("Received new RARE ship as drop.") Utils.touch_randomly(self.region['dismiss_ship_drop']) Utils.script_sleep(2) - continue + continue elif Utils.find("menu/drop_ssr"): Logger.log_msg("Received SSR ship as drop.") Utils.touch_randomly(self.region['dismiss_ship_drop']) @@ -488,7 +488,7 @@ def movement_handler(self, target_info): def unable_handler(self, coords, boss=False): """ - Method called when the path to the target (boss fleet or mystery node) is obstructed by mobs: + Method called when the path to the target (boss fleet or mystery node) is obstructed by mobs: it procedes to switch targets to the mobs which are blocking the path. Args: @@ -643,7 +643,7 @@ def clear_map(self): translation_module = 175 if boss_region.y > 300 else 75 horizontal_translation = translation_sign * translation_module angular_coefficient = -1 * ((540 - boss_region.y)/(960 - boss_region.x)) - Utils.swipe(boss_region.x + horizontal_translation, boss_region.y + int(horizontal_translation * angular_coefficient), + Utils.swipe(boss_region.x + horizontal_translation, boss_region.y + int(horizontal_translation * angular_coefficient), 960 + horizontal_translation, 540 + int(horizontal_translation * angular_coefficient), 300) Utils.wait_update_screen() @@ -701,6 +701,24 @@ def clear_boss(self, boss_info): #handle boss' coordinates if not self.unable_handler(boss_info[0:2], boss=True): return + swipes = { + 0: lambda: Utils.swipe(960, 240, 960, 940, 300), + 1: lambda: Utils.swipe(1560, 540, 260, 540, 300), + 2: lambda: Utils.swipe(960, 940, 960, 240, 300), + 3: lambda: Utils.swipe(260, 540, 1560, 540, 300) + } + + Utils.touch_randomly(self.region['button_switch_fleet']) + Utils.wait_update_screen(2) + boss_region = Utils.find_in_scaling_range("enemy/fleet_boss", similarity=0.9) + s = 0 + while not boss_region: + if s > 3: s = 0 + swipes.get(s)() + Utils.wait_update_screen(0.5) + boss_region = Utils.find_in_scaling_range("enemy/fleet_boss", similarity=0.9) + s += 1 + boss_info = [boss_region.x + 50, boss_region.y + 25, "boss"] continue else: self.movement_handler(boss_info) @@ -810,7 +828,7 @@ def get_enemies(self, blacklist=[], boss=False): l7 = [x for x in l7 if (not self.filter_blacklist(x, blacklist))] Logger.log_debug("L7 " +str(l7)) self.enemies_list.extend(l7) - + sim -= 0.005 if filter_coordinates: @@ -822,7 +840,7 @@ def get_mystery_nodes(self, blacklist=[], boss=False): """ if len(blacklist) > 2: self.mystery_nodes_list.clear() - + if len(self.mystery_nodes_list) == 0 and not Utils.find('combat/question_mark', 0.9): # if list is empty and a question mark is NOT found return self.mystery_nodes_list @@ -842,10 +860,10 @@ def get_mystery_nodes(self, blacklist=[], boss=False): self.mystery_nodes_list = l1 sim -= 0.005 - + if filter_coordinates: self.mystery_nodes_list = Utils.filter_similar_coords(self.mystery_nodes_list) - + return self.mystery_nodes_list def filter_blacklist(self, coord, blacklist): @@ -888,7 +906,7 @@ def get_fleet_location(self): coords = [0, 0] self.fleet_location = coords - + return self.fleet_location def get_closest_target(self, blacklist=[], location=[], mystery_node=False, boss=False): @@ -907,7 +925,7 @@ def get_closest_target(self, blacklist=[], location=[], mystery_node=False, boss Returns: array: An array containing the x and y coordinates of the closest enemy to the specified location - """ + """ fleet_location = self.get_fleet_location() if location == []: @@ -926,7 +944,7 @@ def get_closest_target(self, blacklist=[], location=[], mystery_node=False, boss else: # target only enemy mobs targets = self.get_enemies(blacklist, boss) - + closest = targets[Utils.find_closest(targets, location)[1]] Logger.log_info('Current location is: {}'.format(fleet_location))