def set_filters(self): """Filters the ship list to only show rare and commmon ships """ Utils.touch_randomly(Region(1090, 15, 150, 40)) Utils.script_sleep(1) Utils.wait_for_exist('ship_filter_confirm', 3) Utils.touch_randomly(Region(300, 570, 100, 20)) Utils.find_and_touch('ship_filter_rarity_common') Utils.find_and_touch('ship_filter_rarity_rare') Utils.find_and_touch('ship_filter_confirm')
def clear_boss(self): """Finds the boss and battles it """ while not Utils.exists('combat_battle_start'): boss = None similarity = 0.8 while boss is None: boss = Utils.scroll_find('combat_enemy_boss_alt', 250, 175, similarity) similarity -= 0.015 Logger.log_msg('Boss found at: {}'.format([boss.x, boss.y])) Logger.log_msg('Focusing on boss') Utils.swipe(boss.x, boss.y, 640, 360, 250) boss = None while boss is None: boss = Utils.find('combat_enemy_boss_alt', similarity) similarity -= 0.015 # Click slightly above boss to be able to click on it in case # the boss is obstructed by another fleet or enemy boss_coords = [boss.x + 50, boss.y - 15] Utils.touch(boss_coords) if Utils.wait_for_exist('combat_unable', 3): boss = Utils.scroll_find('combat_enemy_boss_alt', 250, 175, 0.75) enemies = Utils.find_all('combat_enemy_fleet', 0.89) enemies.remove(boss) closest_to_boss = enemies[Utils.find_closest(enemies, boss)[1]] Utils.find_and_touch(closest_to_boss) if Utils.wait_for_exist('combat_unable', 3): Utils.find_and_touch(self.get_closest_enemy()) if Utils.wait_for_exist('combat_battle_start', 3): self.conduct_battle() else: Utils.script_sleep(5) if Utils.find_and_touch('combat_evade'): if Utils.wait_for_exist('combat_battle_start', 3): self.conduct_battle() self.refocus_fleet() elif Utils.find_and_touch('combat_items_received'): pass if self.conduct_prebattle_check(): self.conduct_battle()
def clear_trash(self): """Finds trash mobs closest to the current fleet location and battles them until the boss spawns """ while self.kills_needed > 0: blacklist = [] tries = 0 if self.resume_previous_sortie: self.resume_previous_sortie = False Utils.find_and_touch('combat_attack') Utils.script_sleep(2) else: self.avoided_ambush = True while not Utils.exists('combat_battle_start'): if Utils.find_and_touch('combat_evade'): if Utils.wait_for_exist('combat_battle_start', 3): self.avoided_ambush = False else: Logger.log_msg('Successfully avoided ambush.') elif Utils.find_and_touch('combat_items_received'): pass else: enemy_coord = self.get_closest_enemy() if tries > 2: blacklist.append(enemy_coord) enemy_coord = self.get_closest_enemy(blacklist) Logger.log_msg( 'Navigating to enemy fleet at {}'.format(enemy_coord)) Utils.touch(enemy_coord) tries += 1 Utils.script_sleep(5) if self.conduct_prebattle_check(): if self.conduct_battle(): self.need_to_refocus = True else: self.resume_previous_sortie = True while not (Utils.exists('home_menu_build')): Utils.touch_randomly(self.region['nav_back']) # Add logic for retirement here? return False if self.avoided_ambush: self.kills_needed -= 1 Logger.log_msg('Kills left for boss to spawn: {}'.format( self.kills_needed)) Utils.script_sleep(1) return True
def conduct_battle(self): """Method to start the battle and click through the rewards once the battle is complete. """ Logger.log_msg('Starting battle') while (Utils.exists('combat_auto_enabled')): Utils.touch_randomly(self.region['battle_start']) if Utils.wait_for_exist('combat_notification_sort', 3): return False Utils.script_sleep(30) while not Utils.find_and_touch('combat_battle_confirm', 0.85): if Utils.find_and_touch('confirm'): Logger.log_msg('Locked new ship.') else: Utils.touch_randomly(Region(0, 100, 150, 150)) Utils.script_sleep() Logger.log_msg('Battle complete.') if Utils.wait_and_touch('confirm', 3): Logger.log_msg('Dismissing urgent notification.') return True