Пример #1
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)
Пример #2
0
    def set_sort(self):
        """Method which sets the correct filters for retirement.
        """
        if self.config.enhancement['enabled'] and (
                self.previous_call_place == "combat"
                or not self.called_from_menu):
            # Reset self.sorted if the request to retire 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 retirement
            # module is called only if the enhancement module fails
            # (e.g. no common ships unlocked in dock).
            self.sorted = False
        if not self.build_menu_sorted and self.called_from_menu:
            # addressing case of only retirement module enabled and first place
            # it's called from is combat: self.sorted is set to true, but the filters
            # enabled when accessing from menu are separated from the ones in combat,
            # so they are not set. self.build_menu_sorted flag ensures that
            # the sorting procedure is done at least once when accessing to
            # retirement from main menu.
            self.build_menu_sorted = True
            self.sorted = False
        if not self.combat_sorted and not self.called_from_menu:
            # addressing case of only retirement module enabled and first place
            # it's called from is main menu: self.sorted is set to true, but the filters
            # enabled when accessing from combat are separated from the ones in menu,
            # so they are not set. self.combat_sorted flag ensures that
            # the sorting procedure is done at least once when accessing to
            # retirement from combat.
            self.combat_sorted = True
            self.sorted = False
        Logger.log_debug("Retirement: " + repr(self.config.retirement))
        while not self.sorted:
            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['rarity_all_ship_filter'])
            Utils.script_sleep(0.5)
            Utils.touch_randomly(self.region['extra_all_ship_filter'])
            Utils.script_sleep(0.5)
            if self.config.retirement['commons']:
                Utils.touch_randomly(self.region['common_ship_filter'])
                Utils.script_sleep(0.5)
            if self.config.retirement['rares']:
                Utils.touch_randomly(self.region['rare_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:
                retirements = (self.config.retirement['commons'],
                               self.config.retirement['rares'], True)
                checks = [False, 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.config.retirement['commons'] and self.region[
                            'common_ship_filter'].equal_approximated(
                                option, 25):
                        Logger.log_debug("Retirement: Sorting commons")
                        checks[0] = True
                    if self.config.retirement['rares'] and self.region[
                            'rare_ship_filter'].equal_approximated(option, 25):
                        Logger.log_debug("Retirement: Sorting rares")
                        checks[1] = True
                    if self.region['extra_all_ship_filter'].equal_approximated(
                            option, 25):
                        Logger.log_debug(
                            "Retirement: Extra All option enabled")
                        checks[2] = True
                if retirements == tuple(checks) and len(options) <= 3:
                    Logger.log_debug("Retirement: Sorting options confirmed")
                    self.sorted = True
            Utils.touch_randomly(self.region['confirm_filter_button'])
            Utils.script_sleep(1)