Esempio n. 1
0
    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
Esempio n. 2
0
    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
Esempio n. 3
0
    def refill_dorm(self):
        """
        This method refill the dorm supplies with 10 oxy cola (150 minutes) if the supplies bar is empty.
        """

        Utils.script_sleep(5)
        Logger.log_debug("Refilling dorm supplies if empty.")

        while True:
            Utils.wait_update_screen(1)
            if Utils.find("headquarters/dorm_summary_confirm_button"):
                # dismiss dorm summary, if any
                Utils.touch_randomly(self.region["confirm_dorm_summary"])
                continue
            if Utils.find("headquarters/give_food_button"):
                # dismiss notification by tapping ignore
                Utils.touch_randomly(self.region["ignore_give_food_button"])
                continue
            if self.get_dorm_bar_empty(self.start_feed_threshold, True):
                # proceed to refill
                self.feed_snacks()
                break
            else:
                # exit loop
                Logger.log_debug("Ending refill loop.")
                break
Esempio n. 4
0
    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
Esempio n. 5
0
    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
Esempio n. 6
0
    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
Esempio n. 7
0
    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)
Esempio n. 8
0
    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
Esempio n. 9
0
    def conduct_prebattle_check(self):
        """Method to check morale and check if auto-battle is enabled before a
        sortie. Enables autobattle if not already enabled.

        Returns:
            bool: True if it is ok to proceed with the battle
        """
        ok = True
        fleet_morale = self.check_morale()
        if fleet_morale['sad']:
            self.set_next_combat_time({'hours': 2})
            ok = False
        elif fleet_morale['neutral']:
            self.set_next_combat_time({'hours': 1})
            ok = False
        else:
            if not self.combat_auto_enabled:
                Logger.log_msg('Checking if auto-battle is enabled.')
                if not Utils.exists('combat_auto_enabled'):
                    Logger.log_msg('Enabling auto-battle')
                    Utils.touch_randomly(self.region['toggle_autobattle'])
                    Utils.script_sleep(0.5)
                    Utils.touch_randomly(Region(600, 100, 150, 150))
                    Utils.script_sleep(2)
                self.combat_auto_enabled = True
        return ok
Esempio n. 10
0
    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)
Esempio n. 11
0
    def refill_dorm(self):
        """
        This method refill the dorm supplies with 10 oxy cola (150 minutes) if the supplies bar is empty.
        """

        Utils.script_sleep(5)
        Logger.log_debug("Refilling dorm supplies if empty.")

        while True:
            Utils.wait_update_screen(1)
            if Utils.find("headquarters/dorm_summary_confirm_button"):
                # dismiss dorm summary, if any
                Utils.touch_randomly(self.region["confirm_dorm_summary"])
                continue
            if Utils.find("headquarters/give_food_button"):
                # dismiss notification by tapping ignore
                Utils.touch_randomly(self.region["ignore_give_food_button"])
                continue
            if Utils.find("headquarters/supplies_bar_empty"):
                # proceed to refill
                Utils.touch_randomly(self.region["supplies_bar"])
                Utils.script_sleep(1)
                # tap oxy cola ten times
                for i in range(0, 10):
                    Utils.touch_randomly(self.region["oxy_cola"])
                Logger.log_msg("Refilled dorm supplies.")
                # tap out
                Utils.touch_randomly(self.region["exit_snacks_menu"])
            else:
                # exit loop
                Logger.log_debug("Ending refill loop.")
                break
Esempio n. 12
0
    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
Esempio n. 13
0
    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
Esempio n. 14
0
    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
Esempio n. 15
0
    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
Esempio n. 16
0
 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)
Esempio n. 17
0
    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
Esempio n. 18
0
    def set_sort(self):
        """Method which sets the correct filters for enhancement, i.e. 'Enhanceable' option.
        """
        if self.config.retirement['enabled'] and (
                self.previous_call_place == "combat"
                or not self.called_from_menu):
            # Reset self.sorted if the request to enhance came from combat
            # this time or the previous time. The check is necessary because
            # the filters for enhancement and retirement in combat are shared.
            # If the alert "dock is full" is encountered, the enhancement
            # module is called without doubts even if it ends up not enhancing
            # (e.g. no common ships unlocked in dock).
            self.sorted = False
        while not self.sorted:
            Logger.log_debug("Enhancement: 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['rarity_all_ship_filter'])
            Utils.script_sleep(0.5)
            Utils.touch_randomly(self.region['extra_all_ship_filter'])
            Utils.script_sleep(0.5)
            # Touch the Enhanceable button
            Utils.touch_randomly(self.region['extra_enhanceable_ship_filter'])
            Utils.script_sleep(0.5)

            # check if correct options are enabled
            # get the regions of enabled options
            options = Utils.get_enabled_ship_filters(
                filter_categories="rarity;extra")
            if len(options) == 0:
                # if the list is empty it probably means that there was an ui update
                # pausing and requesting for user confirmation
                Logger.log_error("No options detected. User's input required.")
                input(
                    "Manually fix sorting options. Press Enter to continue...")
                self.sorted = True
            else:
                checks = [False, False]
                for option in options:
                    # tolerance is set to 25 since the regions chosen for tapping are smaller than the actual ones
                    if self.region[
                            'rarity_all_ship_filter'].equal_approximated(
                                option, 25):
                        Logger.log_debug(
                            "Enhancement: Rarity All option enabled")
                        checks[0] = True
                    if self.region[
                            'extra_enhanceable_ship_filter'].equal_approximated(
                                option, 25):
                        Logger.log_debug(
                            "Enhancement: Enhanceable option enabled")
                        checks[1] = True
                if checks[0] and checks[1]:
                    Logger.log_debug("Enhancement: Sorting options confirmed")
                    self.sorted = True
            Utils.touch_randomly(self.region['confirm_filter_button'])
            Utils.script_sleep(1)
Esempio n. 19
0
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")
Esempio n. 20
0
    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
Esempio n. 21
0
 def retire_ships(self):
     """Clicks through the dialogs for retiring ships
     """
     Utils.find_and_touch('retire_confirm', 0.8)
     Utils.wait_and_touch('retire_confirm', 0.8, 3)
     Utils.touch_randomly(Region(0, 0, 300, 300))
     Utils.wait_and_touch('retire_confirm', 0.8, 3)
     Utils.wait_and_touch('retire_disassemble', 3)
     Utils.touch_randomly(Region(0, 0, 300, 300))
Esempio n. 22
0
def CheckLogistic():
    Utils.script_sleep(3)

    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")
        CheckLogistic()
Esempio n. 23
0
 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')
Esempio n. 24
0
 def select_ships(self):
     """Selects up to 10 ships for retirement
     """
     Logger.log_msg('Selecting ships for retirement.')
     x, y = 90, 180
     for i in range(0, 7):
         Utils.touch_randomly(Region(x + (i * 170), y, 30, 15))
     y = 412
     for i in range(0, 3):
         Utils.touch_randomly(Region(x + (i * 170), y, 30, 15))
Esempio n. 25
0
 def mission_logic_wrapper(self):
     if (Utils.find_and_touch('mission_complete')):
         Logger.log_msg('Checking for completed missions.')
         self.stats.increment_missions_done()
         Utils.script_sleep(0.5)
         while Utils.find_and_touch('collect_mission'):
             Utils.touch_randomly()
         Utils.touch_randomly(Region(12, 8, 45, 30))
         return True
     return False
Esempio n. 26
0
    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
Esempio n. 27
0
    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():
                if self.commission_start_attempts > 10:
                    Logger.log_warning("Going back to main menu and retrying.")
                else:
                    Logger.log_msg("No more commissions to start.")
                return
Esempio n. 28
0
    def start_daily(self):

        while True:

            if Utils.find("combat/battle_button"):
                Utils.touch_randomly(self.region["menu_combat_start"])
                Logger.log_debug(
                    "Found battle button, starting clear function.")
                self.daily_handler()
            if Utils.find("combat/daily_out"):
                Logger.log_info("You're out of daily stage challenges.")
                Utils.touch_randomly(self.region["menu_nav_back"])
            Utils.update_screen()
Esempio n. 29
0
    def pre_combat_handler(self):
        """Handles pre-combat stuff like fleet selection and starts combat_handler function.
        """
        while True:
            Utils.update_screen()

            if Utils.find("combat/menu_select_fleet"):
                Logger.log_debug("Found event fleet go button.")
                Utils.touch_randomly(self.region['menu_fleet_go'])
                continue
            if Utils.find("combat/menu_formation"):
                Logger.log_debug("Found formation asset.")
                return True
Esempio n. 30
0
    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