def start_commission(self): Logger.log_debug("Starting commission.") tapped_recommend = False while True: Utils.update_screen() if self.commission_start_attempts > 10: Logger.log_warning("Failed to start commission.") Utils.touch_randomly(self.region["dismiss_message"]) break if Utils.find("commission/alert_begun"): Logger.log_msg("Successfully started commission.") Utils.touch_randomly(self.region["dismiss_message"]) self.stats.increment_commissions_started() break if Utils.find("menu/button_confirm"): Logger.log_debug("Found commission oil warning message.") Utils.touch_randomly(self.region["oil_warning"]) continue if tapped_recommend and Utils.find("commission/button_ready"): Logger.log_debug("Found commission start button.") Utils.touch_randomly(self.region["commission_start"]) tapped_recommend = False continue if Utils.find("commission/button_recommend"): Logger.log_debug("Found commission recommend button.") Utils.touch_randomly(self.region["commission_recommend"]) tapped_recommend = True self.commission_start_attempts += 1 continue Utils.wait_update_screen(1) return not (Utils.find("commission/commissions_full") or self.commission_start_attempts > 10)
def get_closest_target(self, blacklist=[], location=[], mystery_node=False): """Method to get the enemy closest to the specified location. Note this will not always be the enemy that is actually closest due to the asset used to find enemies and when enemies are obstructed by terrain or the second fleet Args: blacklist(array, optional): Defaults to []. An array of coordinates to exclude when searching for the closest enemy location(array, optional): Defaults to []. An array of coordinates to replace the fleet location. Returns: array: An array containing the x and y coordinates of the closest enemy to the specified location """ while True: fleet_location = self.get_fleet_location() mystery_nodes = [] if location == []: location = fleet_location enemies = self.get_enemies(blacklist) if mystery_node: sim = 0.9 while mystery_nodes == []: Utils.update_screen() l1 = filter( lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180, Utils.find_all('combat/question_mark', sim)) l1 = [x for x in l1 if (x not in blacklist)] mystery_nodes = l1 sim -= 0.005 mystery_nodes = Utils.filter_similar_coords(mystery_nodes) targets = enemies + mystery_nodes closest = targets[Utils.find_closest(targets, location)[1]] Logger.log_info('Current location is: {}'.format(fleet_location)) Logger.log_info('Enemies found at: {}'.format(targets)) Logger.log_info('Closest enemy is at {}'.format(closest)) if closest in self.l: x = self.l.index(closest) del self.l[x] if mystery_node and closest in mystery_nodes: return [closest[0], closest[1], "mystery_node"] else: return [closest[0], closest[1], "enemy"]
def retire_ships(self): while True: Utils.update_screen() if Utils.find("retirement/selected_none") and self.sorted == False: Logger.log_debug("Opening sorting menu.") Utils.touch_randomly(self.region['sort_filters_button']) continue if Utils.find("retirement/button_sort_all", 0.99): Logger.log_debug("Changing sorting options for retirement.") Utils.touch_randomly(self.region['common_ship_filter']) Utils.script_sleep(0.5) Utils.touch_randomly(self.region['rare_ship_filter']) Utils.script_sleep(0.5) continue if Utils.find( "retirement/button_sort_common", 0.99) and Utils.find( "retirement/button_sort_rare", 0.99): Logger.log_msg("Sorting options for retirement are correct.") self.sorted = True Utils.touch_randomly(self.region['confirm_filter_button']) Utils.script_sleep(1) continue if Utils.find("retirement/empty"): Logger.log_msg("No ships left to retire.") Utils.touch_randomly(self.region['menu_nav_back']) return if Utils.find("retirement/selected_none"): self.select_ships() continue if Utils.find("retirement/bonus"): self.handle_retirement() continue
def combat_handler(self): Logger.log_msg("Starting combat.") Utils.touch_randomly(self.region['menu_combat_start']) Utils.script_sleep(4) while True: Utils.update_screen() if Utils.find("combat/combat_pause", 0.7): Logger.log_debug("In battle.") Utils.script_sleep(5) continue if Utils.find("combat/menu_touch2continue"): Utils.touch_randomly(self.region['tap_to_continue']) continue if Utils.find("menu/item_found"): Utils.touch_randomly(self.region['tap_to_continue']) Utils.script_sleep(1) continue if Utils.find("combat/button_confirm"): Logger.log_msg("Combat ended.") Utils.touch_randomly(self.region['combat_end_confirm']) self.stats.increment_combat_done() Utils.script_sleep(1) return if Utils.find("combat/menu_combat_finished"): Utils.touch_randomly(self.region['dismiss_combat_finished']) Utils.script_sleep(1) continue
def mission_logic_wrapper(self): while True: Utils.update_screen() if Utils.find("mission/alert_completed"): Logger.log_msg("Found mission completed alert.") Utils.touch_randomly(self.region["mission_menu"]) continue if Utils.find("menu/drop_ssr"): Logger.log_msg("Received SSR ship as reward.") Utils.touch_randomly(self.region['dismiss_ship_drop']) continue if Utils.find("menu/drop_elite"): Logger.log_msg("Received ELITE ship as reward.") Utils.touch_randomly(self.region['dismiss_ship_drop']) continue while Utils.find("menu/missions"): Utils.update_screen() if Utils.find("mission/button_collect"): Logger.log_msg("Collected all missions.") Utils.touch_randomly(self.region["collect"]) Utils.script_sleep(3) continue if Utils.find("mission/button_claim"): Logger.log_msg("Claimed mission.") Utils.touch_randomly(self.region["first_claim"]) continue if Utils.find("menu/item_found"): Utils.touch_randomly(self.region["tap_to_continue"]) continue else: Logger.log_msg("No more missions to claim/collect.") Utils.menu_navigate("menu/button_battle") return True
def set_sort(self): while not self.sorted: Utils.update_screen() if Utils.find("retirement/selected_none"): Logger.log_debug("Retirement: Opening sorting menu.") Utils.touch_randomly(self.region['sort_filters_button']) Utils.script_sleep(0.5) # Touch the All button to clear any current filter Utils.touch_randomly(self.region['all_ship_filter']) continue if self.config.retirement['commons'] and not Utils.find( "retirement/button_sort_common", 0.99): Logger.log_debug("Retirement: Sorting commons") Utils.touch_randomly(self.region['common_ship_filter']) Utils.script_sleep(0.5) continue if self.config.retirement['rares'] and not Utils.find( 'retirement/button_sort_rare', 0.99): Logger.log_debug("Retirement: Sorting rares") Utils.touch_randomly(self.region['rare_ship_filter']) Utils.script_sleep(0.5) continue Logger.log_debug("Retirement: Confirming sort options") self.sorted = True Utils.touch_randomly(self.region['confirm_filter_button']) Utils.script_sleep(1)
def feed_snacks(self): Utils.touch_randomly(self.region["supplies_bar"]) Utils.script_sleep(1) Utils.update_screen() alert_found = Utils.find("menu/alert_close") retry_counter = 0 while retry_counter < 40 and self.get_dorm_bar_empty( self.stop_feed_threshold) and not alert_found: retry_counter += 1 find_food = False for idx in self.supply_order: region = self.supply_region[idx] if Utils.get_region_color_average( region)[2] < self.supply_whiteout_threshold: Utils.touch_randomly(region) find_food = True break if not find_food: break else: Utils.wait_update_screen(0.5) alert_found = Utils.find("menu/alert_close") if alert_found: Utils.touch_randomly(alert_found) Utils.wait_update_screen(1) # tap out Utils.touch_randomly(self.region["exit_snacks_menu"])
def select_daily(self): Utils.wait_update_screen(1) # while True: if not Utils.find("combat/daily_attempts"): Utils.touch_randomly(self.region["center_daily"]) Logger.log_info("Found daily challenge.") Utils.script_sleep(1) Utils.update_screen() # continue if Utils.find("combat/daily_attempts"): Utils.touch_randomly(self.region["select_daily"]) Logger.log_info("Select daily challenge.") Utils.script_sleep(1) Utils.update_screen() # continue if Utils.find("combat/daily_out"): Logger.log_info("You're out of daily stage challenges.") Utils.touch_randomly(self.region["menu_nav_back"]) # return True Utils.wait_update_screen(1) self.start_daily()
def get_mystery_nodes(self, blacklist=[], boss=False): """Method which returns a list of mystery nodes' coordinates. """ 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 else: # list has elements or list is empty but a question mark has been found filter_coordinates = True if len(self.mystery_nodes_list) == 0 else False sim = 0.95 while not self.mystery_nodes_list and sim > 0.93: Utils.update_screen() l1 = filter(lambda x:(x[1] > 242 and x[1] < 1070 and x[0] > 180 and x[0] < 955) or (x[1] > 160 and x[1] < 938 and x[0] > 550 and x[0] < 1790), map(lambda x:[x[0], x[1] + 140], Utils.find_all('combat/question_mark', sim))) l1 = [x for x in l1 if (not self.filter_blacklist(x, blacklist))] 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 unable_handler(self, coords): """ Method called when the path to the boss fleet is obstructed by mobs: it procedes to switch targets to the mobs which are blocking the path. Args: coords (list): coordinate_x, coordinate_y. These coordinates describe the boss location. """ Logger.log_debug("Unable to reach boss function started.") closest_to_boss = self.get_closest_target(self.blacklist, coords) Utils.touch(closest_to_boss) Utils.wait_update_screen(1) if Utils.find("combat/alert_unable_reach"): Logger.log_warning("Unable to reach next to boss.") self.blacklist.append(closest_to_boss) while True: closest_enemy = self.get_closest_target(self.blacklist) Utils.touch(closest_enemy) Utils.update_screen() if Utils.find("combat/alert_unable_reach"): self.blacklist.append(closest_to_boss) else: break self.movement_handler(closest_enemy) self.battle_handler() return else: self.movement_handler(closest_to_boss) self.battle_handler() return
def combat_handler(self): Logger.log_msg("Starting combat.") Utils.touch_randomly(self.region['menu_combat_start']) Utils.script_sleep(4) while True: Utils.update_screen() if Utils.find("combat/combat_pause", 0.7): Logger.log_debug("In battle.") Utils.script_sleep(5) continue if Utils.find("combat/menu_touch2continue"): Utils.touch_randomly(Region(661, 840, 598, 203)) continue if Utils.find("menu/item_found"): Utils.touch_randomly(Region(661, 840, 598, 203)) Utils.script_sleep(1) continue if Utils.find("combat/button_confirm"): Logger.log_msg("Combat ended.") Utils.touch_randomly(Region(1520, 963, 216, 58)) Utils.script_sleep(1) return if Utils.find("combat/menu_combat_finished"): Utils.touch_randomly(Region(725, 965, 647, 76)) Utils.script_sleep(1) continue
def retreat_handler(self): Logger.log_msg("Retreating...") while True: Utils.update_screen() if Utils.find("combat/alert_morale_low"): Utils.touch_randomly(Region(613, 731, 241, 69)) self.exit = 2 continue if Utils.find("menu/button_sort"): Utils.touch_randomly(Region(1312, 263, 64, 56)) self.exit = 3 continue if Utils.find("combat/menu_formation"): Utils.touch_randomly(self.region["menu_nav_back"]) continue if Utils.find("combat/button_retreat"): Utils.touch_randomly(Region(1130, 985, 243, 60)) continue if Utils.find("commission/button_confirm"): Utils.touch_randomly(Region(1065, 732, 235, 68)) continue if Utils.find("menu/attack"): return
def handle_retirement(self): Utils.touch_randomly(Region(1510, 978, 216, 54)) items_found = 0 while True: Utils.update_screen() if Utils.find("retirement/alert_bonus"): Utils.touch_randomly(Region(1412, 938, 218, 61)) Utils.script_sleep(1) continue if Utils.find("menu/item_found"): Utils.touch_randomly(Region(661, 840, 598, 203)) Utils.script_sleep(1) items_found += 1 if items_found > 1: return continue if Utils.find("menu/alert_info"): Utils.touch_randomly(Region(1320, 785, 232, 62)) Utils.script_sleep(1) continue if Utils.find("retirement/button_disassemble"): Utils.touch_randomly(Region(1099, 827, 225, 58)) Utils.script_sleep(1) continue
def retire_ships(self): while True: Utils.update_screen() if Utils.find("retirement/selected_none") and self.sorted == False: Logger.log_debug("Opening sorting menu.") Utils.touch_randomly(Region(1655, 14, 130, 51)) continue if Utils.find("retirement/button_sort_all", 0.99): Logger.log_debug("Changing sorting options for retirement.") Utils.touch_randomly(Region(672, 724, 185, 41)) Utils.script_sleep(0.5) Utils.touch_randomly(Region(911, 724, 185, 41)) Utils.script_sleep(0.5) continue if Utils.find("retirement/button_sort_common") and Utils.find( "retirement/button_sort_rare"): Logger.log_msg("Sorting options for retirement are correct.") self.sorted = True Utils.touch_randomly(Region(1090, 969, 220, 60)) Utils.script_sleep(1) continue if Utils.find("retirement/empty"): Logger.log_msg("No ships left to retire.") Utils.touch_randomly(Region(54, 57, 67, 67)) return if Utils.find("retirement/selected_none"): self.select_ships() continue if Utils.find("retirement/bonus"): self.handle_retirement() continue
def retreat_handler(self): """ Retreats if necessary. """ force_retreat = True if self.exit != 1 else False pressed_retreat_button = False while True: Utils.update_screen() if Utils.find("combat/menu_formation"): Utils.touch_randomly(self.region["menu_nav_back"]) Utils.script_sleep(1) continue if force_retreat and (not pressed_retreat_button ) and Utils.find("combat/button_retreat"): Logger.log_msg("Retreating...") Utils.touch_randomly(self.region['retreat_button']) pressed_retreat_button = True Utils.script_sleep(1) continue if Utils.find_and_touch("menu/button_confirm"): # confirm either the retreat or an urgent commission alert Utils.script_sleep(1) continue if Utils.find("menu/attack"): return
def enhancement_logic_wrapper(self): """Method that fires off the necessary child methods that encapsulates the entire action of enhancing a ship """ if self.need_to_enhance: self.last_enhance = self.stats.combat_done Logger.log_msg("Opening dock to enhance ship.") while True: Utils.update_screen() if Utils.find("menu/button_battle"): Utils.touch_randomly(self.region['dock_tab']) Utils.script_sleep(1) continue if Utils.find("enhancement/button_favorite", 0.99): self.enhance_ship() Utils.touch_randomly(self.region['button_favorite']) Utils.touch_randomly(self.region['button_go_back']) return if Utils.find("menu/dock"): Utils.touch_randomly(self.region['button_favorite']) continue else: Utils.touch_randomly(self.region['button_go_back']) Utils.script_sleep(2)
def mission_logic_wrapper(self): while True: Utils.update_screen() if Utils.find("mission/alert_completed"): Logger.log_msg("Found mission completed alert.") Utils.touch_randomly(self.region["mission_menu"]) continue if Utils.find("menu/drop_ssr"): Logger.log_msg("Received SSR ship as reward.") Utils.touch_randomly(Region(1228, 103, 692, 735)) continue if Utils.find("menu/drop_elite"): Logger.log_msg("Received ELITE ship as reward.") Utils.touch_randomly(Region(1228, 103, 692, 735)) continue while Utils.find("menu/missions"): Utils.update_screen() if Utils.find("mission/button_collect"): Logger.log_msg("Collected all missions.") Utils.touch_randomly(self.region["collect"]) continue if Utils.find("mission/button_claim"): Logger.log_msg("Claimed mission.") Utils.touch_randomly(self.region["first_claim"]) continue if Utils.find("menu/item_found"): Utils.touch_randomly(Region(661, 840, 598, 203)) continue else: Logger.log_msg("No more missions to claim/collect.") Utils.touch_randomly(self.region["button_back"]) return True
def retreat_handler(self): """ Retreats if necessary. """ while True: Utils.update_screen() if Utils.find("combat/alert_morale_low"): Utils.touch_randomly(self.region['close_info_dialog']) self.exit = 2 continue if Utils.find("menu/button_sort"): Utils.touch_randomly(self.region['close_info_dialog']) self.exit = 3 continue if Utils.find("combat/menu_formation"): Utils.touch_randomly(self.region["menu_nav_back"]) continue if Utils.find("combat/button_retreat"): Utils.touch_randomly(self.region['retreat_button']) continue if Utils.find("menu/button_confirm"): Utils.touch_randomly(self.region['dismiss_commission_dialog']) continue if Utils.find("menu/attack"): if self.exit != 1 and self.exit != 4 and self.exit != 5: Logger.log_msg("Retreating...") return
def movement_handler(self, target_info): """ Method that handles the fleet movement until it reach its target (mystery node or enemy node). If the coordinates are wrong, they will be blacklisted and another set of coordinates to work on is obtained. If the target is a mystery node and what is found is ammo, then the method will fall in the blacklist case and search for another enemy: this is inefficient and should be improved, but it works. Args: target_info (list): coordinate_x, coordinate_y, type. Describes the selected target. Returns: (int): 1 if a fight is needed, otherwise 0. """ Logger.log_msg("Moving towards objective.") count = 0 location = [target_info[0], target_info[1]] Utils.script_sleep(1) while True: Utils.update_screen() event = self.check_movement_threads() if event["combat/button_evade"]: Logger.log_msg("Ambush was found, trying to evade.") Utils.touch_randomly(self.region["combat_ambush_evade"]) Utils.script_sleep(0.5) continue if event["combat/alert_failed_evade"]: Logger.log_warning("Failed to evade ambush.") Utils.touch_randomly(self.region["menu_combat_start"]) self.battle_handler() continue if event["menu/item_found"]: Logger.log_msg("Item found on node.") Utils.touch_randomly(Region(661, 840, 598, 203)) if Utils.find("combat/menu_emergency"): Utils.script_sleep(1) Utils.touch_randomly(self.region["hide_strat_menu"]) if target_info[2] == "mystery_node": Logger.log_msg("Target reached.") return 0 continue if event["menu/alert_info"]: Logger.log_debug("Found alert.") Utils.find_and_touch("menu/alert_close") continue if event["combat/menu_formation"] or event["combat/menu_loading"]: return 1 else: if count != 0 and count % 3 == 0: Utils.touch(location) if count > 21: Logger.log_msg( "Blacklisting location and searching for another enemy." ) self.blacklist.append(location) self.l.clear() location = self.get_closest_target(self.blacklist) count = 0 count += 1
def enhance_ship(self): """ Method that selects the first (leftmost of the first row) favorite ship and proceeds to enhance her. """ #selects ship Utils.touch_randomly(Region(209, 209, 80, 120)) Utils.script_sleep(1) while True: Utils.update_screen() if Utils.find("enhancement/menu_enhance"): Logger.log_debug("Filling with ships.") #taps the "fill" button Utils.touch_randomly(Region(1467, 917, 140, 38)) Utils.update_screen() if Utils.find("enhancement/alert_no_items", 0.85): Logger.log_warning("Not enough ships to enhance.") break if Utils.find("enhancement/menu_level", 0.8): self.handle_retirement() Logger.log_msg("Successfully finished enhancing.") break if Utils.find("enhancement/menu_details"): Logger.log_debug("Opening enhance menu.") if not Utils.find("enhancement/menu_retrofit", 0.9): Utils.touch_randomly(Region(31, 188, 91, 91)) else: Utils.touch_randomly(Region(31, 329, 91, 91)) continue Utils.touch_randomly(self.region['button_go_back']) Utils.script_sleep(1) return
def handle_retirement(self): """ Method that handles the disassembling of the ship materials used in the enhancement process. """ #tap the "enhance" button Utils.touch_randomly(Region(1705, 916, 167, 40)) Utils.update_screen() if not Utils.find("enhancement/alert_enhanced", 0.85): Logger.log_debug("Didn't find enhanced alert.") return else: Logger.log_debug("Successfully enhanced ship.") while True: Utils.update_screen() if Utils.find("menu/alert_info"): Utils.touch_randomly(Region(1320, 785, 232, 62)) Utils.script_sleep(1) continue if Utils.find("retirement/button_disassemble"): Utils.touch_randomly(Region(1099, 827, 225, 58)) Utils.script_sleep(1) continue if Utils.find("menu/item_found"): Utils.touch_randomly(Region(661, 840, 598, 203)) Utils.script_sleep(1) return
def handle_retirement(self): Utils.touch_randomly(self.region['confirm_retire_button']) items_found = 0 while True: Utils.update_screen() if Utils.find("retirement/alert_bonus"): Utils.touch_randomly( self.region['confirm_selected_ships_button']) Utils.script_sleep(1) continue if Utils.find("menu/item_found"): Utils.touch_randomly(self.region['tap_to_continue']) Utils.script_sleep(1) items_found += 1 if items_found > 1: return continue if Utils.find("menu/alert_info"): Utils.touch_randomly( self.region['confirm_selected_equipment_button']) Utils.script_sleep(1) continue if Utils.find("retirement/button_disassemble"): Utils.touch_randomly(self.region['disassemble_button']) Utils.script_sleep(1) continue
def clear_boss(self, boss_info): Logger.log_debug("Started boss function.") self.enemies_list.clear() self.mystery_nodes_list.clear() self.blacklist.clear() while True: #tap at boss' coordinates Utils.touch(boss_info[0:2]) Utils.update_screen() if Utils.find("combat/alert_unable_reach", 0.8): Logger.log_msg("Unable to reach boss.") #handle boss' coordinates if not self.unable_handler(boss_info[0:2]): return continue else: self.movement_handler(boss_info) if self.battle_handler(boss=True): self.exit = 1 Logger.log_msg("Boss successfully defeated.") Utils.script_sleep(3) return
def handle_retirement(self): """ Method that handles the disassembling of the ship materials used in the enhancement process. """ #tap the "enhance" button Utils.touch_randomly(self.region['enhance_orange_button']) #the enhanced alert lasts about three seconds, so there's enough time to catch it #even if the scripts sleeps for a little bit. This pause ensures the script does not take #the screenshot before the alert is shown. Utils.script_sleep(0.5) Utils.update_screen() if not Utils.find("enhancement/alert_enhanced", 0.85): Logger.log_debug("Didn't find enhanced alert.") return else: Logger.log_debug("Successfully enhanced ship.") while True: Utils.update_screen() if Utils.find("menu/alert_info"): Utils.touch_randomly( self.region['confirm_selected_equipment_button']) Utils.script_sleep(1) continue if Utils.find("retirement/button_disassemble"): Utils.touch_randomly(self.region['disassemble_button']) Utils.script_sleep(1) continue if Utils.find("menu/item_found"): Utils.touch_randomly(self.region['tap_to_continue']) Utils.script_sleep(1) return
def retirement_logic_wrapper(self, forced=False): """Method that fires off the necessary child methods that encapsulates the entire action of filtering and retiring ships Args: forced: Forces retirement to start even if need_to_retire returns False. """ if self.need_to_retire or forced: self.last_retire = self.stats.combat_done Logger.log_msg("Opening build menu to retire ships.") while True: Utils.update_screen() if Utils.find("menu/button_sort"): # Tap menu retire button Utils.touch_randomly(Region(549, 735, 215, 64)) Utils.script_sleep(1) continue # In case function is called from menu if Utils.find("menu/button_battle"): Utils.touch_randomly(Region(1452, 1007, 198, 52)) Utils.script_sleep(1) continue if Utils.find("menu/build"): if Utils.find("event/build_limited"): Utils.touch_randomly(Region(30, 816, 94, 94)) else: Utils.touch_randomly(Region(20, 661, 115, 99)) Utils.script_sleep(1) continue if Utils.find("retirement/selected_none"): self.retire_ships() Utils.touch_randomly(Region(54, 57, 67, 67)) return
def enhancement_logic_wrapper(self, forced=False): """Method that fires off the necessary child methods that encapsulates the entire action of enhancing a ship. Args: forced (bool): Forces enhancement to start even if need_to_enhance returns False. Returns: enhancement_done (bool): whether at least one enhancement was completed. """ if self.need_to_enhance or forced: self.last_enhance = self.stats.combat_done self.fill_count = 0 self.called_from_menu = False self.enhancement_done = False Logger.log_msg("Opening dock to enhance ship.") while True: Utils.update_screen() if Utils.find("menu/button_sort"): # Tap enhace button from dock is full alert Utils.touch_randomly(self.region['combat_enhance_button']) Utils.script_sleep(3) continue if Utils.find("menu/button_battle"): Utils.touch_randomly(self.region['dock_tab']) self.called_from_menu = True Utils.script_sleep(2) continue if Utils.find("retirement/empty"): Logger.log_msg("No ships left to enhance.") Utils.touch_randomly(self.region['button_favorite']) Utils.script_sleep(0.5) if self.called_from_menu: Utils.menu_navigate("menu/button_battle") else: Utils.touch_randomly(self.region['button_go_back']) return self.enhancement_done if Utils.find("enhancement/button_favorite", 0.99): Utils.script_sleep(1.0) Utils.touch_randomly(self.region['button_favorite']) Utils.script_sleep(0.5) self.enhance_ship() Utils.script_sleep(1) if self.called_from_menu: self.previous_call_place = "menu" Utils.menu_navigate("menu/button_battle") else: self.previous_call_place = "combat" Utils.touch_randomly(self.region['button_go_back']) return self.enhancement_done if Utils.find("menu/dock"): Utils.touch_randomly(self.region['button_favorite']) Utils.script_sleep(1) self.set_sort() continue else: Utils.touch_randomly(self.region['button_go_back']) Utils.script_sleep(2)
def daily_handler(self): while True: Utils.update_screen() Utils.swipe(960, 680, 960, 400, 300) Utils.touch_randomly(self.region["last_commission"]) if not self.start_commission(): Logger.log_msg("No more commissions to start.") return
def LogisticManager(): while True: Utils.update_screen() if Utils.find("ls_completed"): Utils.touch_randomly() Logger.log_msg("Logistic Mission finished") if Utils.find_and_touch("ls_ok_restart"): Logger.log_msg("Restarting Logistic Mission")
def commission_logic_wrapper(self): """Method that fires off the necessary child methods that encapsulates the entire action of starting and completing commissions. """ Logger.log_msg("Found commission completed alert.") Utils.touch_randomly(self.region["left_menu"]) Utils.script_sleep(1) Utils.touch_randomly(self.region["collect_oil"]) Utils.touch_randomly(self.region["collect_gold"]) self.attempts_count = 0 while True: Utils.update_screen() if Utils.find("commission/button_completed") and ( lambda x: x > 332 and x < 511)( Utils.find("commission/button_completed").y): Logger.log_debug("Found commission complete button.") self.completed_handler() if Utils.find("commission/alert_available", 0.9) and (lambda x: x > 332 and x < 511)(Utils.find( "commission/alert_available", 0.9).y): Logger.log_debug("Found commission available indicator.") if self.attempts_count > 2: Logger.log_msg( "Exceeded number of tries allowed. Resuming with other tasks." ) Utils.touch_randomly(self.region["dismiss_side_tab"]) break Utils.touch_randomly(self.region["button_go"]) self.attempts_count += 1 self.commission_start_attempts = 0 Utils.wait_update_screen(1) while not Utils.find("menu/commission"): Utils.touch_randomly(self.region["button_go"]) Utils.wait_update_screen(1) if Utils.find_and_touch("menu/alert_close"): Utils.script_sleep(1) if self.urgent_handler(): self.daily_handler() Utils.touch_randomly(self.region["button_back"]) continue if Utils.find("commission/button_go") and ( lambda x: x > 332 and x < 511)( Utils.find("commission/button_go").y): Logger.log_msg("All commissions are running.") Utils.touch_randomly(self.region["dismiss_side_tab"]) break Utils.wait_update_screen() return True
def clear_map(self): Logger.log_msg("Started map clear.") Utils.script_sleep(2.5) #hide strat menu Utils.touch_randomly(self.region["hide_strat_menu"]) #swipe map to the left Utils.swipe(960, 540, 1300, 540, 100) target_info = self.get_closest_target(self.blacklist) while True: Utils.update_screen() if Utils.find("combat/alert_unable_battle"): Logger.log_warning("Failed to defeat enemy.") Utils.touch_randomly(Region(869, 741, 185, 48)) return False if self.exit is not 0: return True if Utils.find("enemy/fleet_boss", 0.9): Logger.log_msg("Boss fleet was found.") boss_region = Utils.find("enemy/fleet_boss", 0.9) #extrapolates boss_info(x,y,enemy_type) from the boss_region found boss_info = [boss_region.x + 50, boss_region.y + 25, "boss"] self.clear_boss(boss_info) continue if target_info == None: if Utils.find("combat/question_mark", 0.9): target_info = self.get_closest_target(self.blacklist, mystery_node=True) #if it is a mystery_node (question_mark), tap a bit lower if target_info[2] == "mystery_node": #coord_y += 140 target_info[1] += 140 else: target_info = self.get_closest_target(self.blacklist) continue if target_info: #tap at target's coordinates Utils.touch(target_info[0:2]) Utils.update_screen() if Utils.find("combat/alert_unable_reach", 0.8): Logger.log_warning("Unable to reach the target.") self.blacklist.append(target_info[0:2]) target_info = None continue else: movement_result = self.movement_handler(target_info) if movement_result == 1: self.battle_handler() target_info = None self.blacklist.clear() continue