示例#1
0
 def refocus_fleet(self):
     """Method to refocus on the current fleet
     """
     Logger.log_msg('Refocusing fleet.')
     self.switch_fleet()
     Utils.script_sleep(2)
     self.switch_fleet()
示例#2
0
 def enhance():
     Utils.wait_till_find("factory")
     Utils.touch_randomly(regions["enhance"])
     Utils.wait_till_find_touch("select_character")
     Utils.script_sleep(1)
     gun = None
     gun = Utils.find("enhance_1_l")
     if not gun: gun = Utils.find("enhance_1")
     if not gun: gun = Utils.find("enhance_2_l")
     if not gun: gun = Utils.find("enhance_2")
     if not gun: gun = Region(150, 400, 0, 0)
     Utils.touch_randomly(gun)
     Utils.wait_till_find_touch("select_character_2")
     Utils.wait_till_find_touch("smart_select")
     Utils.script_sleep(2)
     if not Utils.find("smart_select"):
         Utils.touch_randomly(regions["ok"])
         Utils.script_sleep(1)
         Utils.touch_randomly(regions["ok"])
         Utils.script_sleep(2)
         Utils.find_and_touch("ls_ok_restart")
         Utils.touch_randomly(regions["ok"])
         Utils.script_sleep(1)
         Factory.enhance()
     else:
         Utils.touch_randomly(regions["return"])
         Utils.touch_randomly(regions["return"])
         Utils.wait_till_find("test")
示例#3
0
    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"])
示例#4
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
示例#5
0
 def commission_logic_wrapper(self):
     if (Utils.find_and_touch('notification_commission_complete')):
         Logger.log_msg('Completed commissions found.' +
                        'Opening commission panel.')
         while Utils.find_and_touch('commission_complete'):
             Logger.log_msg('Completed commission found.' +
                            'Redeeming reward.')
             Utils.touch_randomly()
             Utils.script_sleep(1)
             Utils.touch_randomly()
             Utils.script_sleep(1)
         if Utils.find_and_touch('commission_go'):
             # Ensure the list is scrolled up to the top before
             # checking in progress commissions
             Utils.swipe(190, 190, 75, 650)
             in_progress = len(
                 Utils.find_all('commission_in_action', 0.87)[0])
             while in_progress < 4:
                 Utils.swipe(190, 190, 650, 75)
                 if Utils.find_and_touch('commission_select'):
                     Utils.find_and_touch('commission_advice')
                     Utils.find_and_touch('commission_start')
                     Utils.touch_randomly(Region(120, 60, 140, 650))
                     in_progress += 1
                 else:
                     break
         Utils.find_and_touch('navigate_back_home')
         Utils.touch_randomly(Region(530, 60, 740, 590))
     return False
示例#6
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)
示例#7
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
示例#8
0
    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()
示例#9
0
    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
示例#10
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
示例#11
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
示例#12
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
示例#13
0
    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
示例#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
示例#15
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]]

        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 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 % 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
示例#16
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)
示例#17
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()
示例#18
0
 def deploy(self, start=True):
     Utils.touch_randomly(Region(950, 550, 0, 0))
     Utils.wait_till_find("echelon_formation")
     Utils.touch_randomly(Region(1800, 1000, 0, 0))
     Logger.log_msg("Echelon deployed")
     if start:
         Utils.touch_randomly(Region(1800, 1000, 0, 0))
         Logger.log_msg("Comencing operation")
         Utils.script_sleep(2)
示例#19
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')
示例#20
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
示例#21
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
示例#22
0
    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
示例#23
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)
示例#24
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
示例#25
0
    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
示例#26
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
示例#27
0
    def collect_dorm_balloons(self):
        """"
        This method finds and collects all the dorm tokens and affinity points visible to the script.
        The various swipes may not work if there is a shipgirl at the starting point of the swipe.
        For this reason the wrapper to this methoed iterates its cycle for three times, refreshing the dorm.
        """
        Utils.script_sleep(1)
        # tap dorm eye in order to hide UI
        Utils.touch_randomly(self.region["dorm_eye_button"])
        Logger.log_debug("Collecting all visible dorm tokens/affinity points.")

        for i in range(0, 4):
            Utils.wait_update_screen(1)
            # since a rather low similarity is used, the variable j ensures a finite loop
            j = 0
            while Utils.find_and_touch("headquarters/dorm_token",
                                       0.75) and j < 5:
                Logger.log_msg("Collected dorm token.")
                Utils.wait_update_screen()
                j += 1
            j = 0
            while Utils.find_and_touch("headquarters/affinity_point",
                                       0.75) and j < 5:
                Logger.log_msg("Collected affinity points.")
                Utils.wait_update_screen()
                j += 1
            if i == 0:
                # swipe right and refresh
                Utils.swipe(960, 540, 560, 540, 300)
                continue
            if i == 1:
                # swipe left (also countering the previous swipe) and refresh
                Utils.swipe(960, 540, 1760, 540, 300)
                continue
            if i == 2:
                # undo previous swipe
                Utils.swipe(960, 540, 560, 540, 300)
                # swipe up and refresh
                Utils.swipe(960, 540, 960, 790, 300)
                continue
            if i == 3:
                # swipe bottom (also countering the previous swipe) and refresh
                Utils.swipe(960, 540, 960, 40, 300)
                continue

        # restore UI
        Utils.touch_randomly(self.region["dorm_eye_button"])
示例#28
0
    def urgent_handler(self):
        Utils.touch_randomly(self.region["urgent_tab"])

        while True:
            Utils.update_screen()

            if Utils.find_and_touch("commission/commission_status"):
                Logger.log_msg("Found status indicator on urgent commission.")
                if not self.start_commission():
                    Logger.log_msg("No more commissions to start.")
                    return False
            else:
                Utils.touch_randomly(self.region["daily_tab"])
                Logger.log_msg("No urgent commissions left.")
                break

        Utils.script_sleep(1)
        return True
示例#29
0
    def research_logic_wrapper(self):
        Logger.log_msg("Found lab alert.")
        Utils.touch_randomly(self.region["lab_tab"])

        while True:
            Utils.wait_update_screen(1)

            if self.config.research['enabled'] and Utils.find(
                    "research/research_academy_alert", 0.99):
                Logger.log_msg("Found research academy alert.")
                Utils.touch_randomly(self.region['research_academy'])
                Utils.script_sleep(1)
                Logger.log_msg("Searching for completed research.")

                if not self.collecting_research():
                    Logger.log_msg("Did not found any completed research.")

                started = False
                Logger.log_msg("Searching for project that matches config.")
                for research_loop in range(0, 5):
                    if not self.research_cycle():
                        Utils.touch_randomly(self.region['right_arrow'])
                    else:
                        if self.start_project() == True:
                            Logger.log_success("Project started.")
                            started = True
                            break
                        else:
                            Logger.log_warning(
                                "Unable to start project. Finding a new one.")
                            Utils.touch_randomly(self.region['right_arrow'])

                if started == False:
                    Logger.log_error(
                        "Unable to find project that matches current configuration."
                    )

                Logger.log_msg("Going back to main menu.")
            else:
                Logger.log_msg(
                    "Shipyard or Fleet Tech alert detected, ignoring it.")
            Utils.touch_randomly(self.region['main_menu_button'])
            Utils.wait_update_screen(1)
            return True
示例#30
0
    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"])

        while True:
            Utils.wait_update_screen(1)
            Utils.avoid_stuck_routine()

            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.")
                Utils.touch_randomly(self.region["button_go"])
                Utils.wait_update_screen(1)

                while not Utils.find("menu/commission"):
                    Utils.touch_randomly(self.region["button_go"])
                    Utils.wait_update_screen(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