コード例 #1
0
ファイル: gui_control.py プロジェクト: D4wN/TinkerforgeRedHab
    def __cb_nfc_state_changed(self, state, idle, nr):
        name = "NO NAME"

        if state == nr.STATE_REQUEST_TAG_ID_READY:
            EventLogger.debug('Tag found')

            # Write 16 byte to pages 5-8
            if self._nfc_write_mode:
                data_write = Utils.string_to_byte_array(self._nfc_write_name)
                nr.write_page(5, data_write)
                EventLogger.debug('Writing data...')
            else:
                nr.request_page(5)
                EventLogger.debug('Requesting data...2')


        elif state == nr.STATE_WRITE_PAGE_READY:  # only when writing before!
            # Request pages 5-8
            nr.request_page(5)
            EventLogger.debug('Requesting data...')

        elif state == nr.STATE_REQUEST_PAGE_READY:
            # Get and print pages
            data = nr.get_page()
            name = str(Utils.byte_array_to_string(data))
            EventLogger.debug('Read data:' + name)

            if self._nfc_cb_to_profiler != None:
                self._nfc_cb_to_profiler(name)

        elif state & (1 << 6):
            # All errors have bit 6 set
            if state == self._nfc.STATE_REQUEST_TAG_ID_ERROR:
                EventLogger.info(
                    'No NFC/RFID Tag found! TODO: Message - Token @ Lesegereat -> Button')  # TODO: Message - Token @ Lesegeraet -> Button
            else:
                EventLogger.debug('Error: ' + str(state))
コード例 #2
0
ファイル: combat.py プロジェクト: KurutsuKaren/ALAuto
    def battle_handler(self, boss=False):
        Logger.log_msg("Starting combat.")

        while not Utils.find("combat/menu_loading", 0.8):
            Utils.update_screen()

            if Utils.find("combat/alert_morale_low") or Utils.find(
                    "menu/button_sort"):
                self.retreat_handler()
                return False
            else:
                Utils.touch_randomly(self.region["menu_combat_start"])
                Utils.script_sleep(1)

        Utils.script_sleep(4)

        while True:
            Utils.update_screen()

            if Utils.find("combat/alert_lock"):
                Logger.log_msg("Locking received ship.")
                Utils.touch_randomly(Region(1086, 739, 200, 55))
                continue
            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"):
                '''if boss:
                    DM.find_droped()
                '''
                Utils.touch_randomly(Region(661, 840, 598, 203))
                Utils.script_sleep(1)
                continue
            if Utils.find("menu/drop_ssr"):
                Logger.log_msg("Received SSR ship as drop.")
                Utils.touch_randomly(Region(1228, 103, 692, 735))
                continue
            if Utils.find("menu/drop_elite"):
                Logger.log_msg("Received ELITE ship as drop.")
                Utils.touch_randomly(Region(1228, 103, 692, 735))
                continue
            if Utils.find("combat/button_confirm"):
                Logger.log_msg("Combat ended.")
                Utils.touch_randomly(self.region["combat_end_confirm"])
                Utils.script_sleep(1)
                if boss:
                    return True
                Utils.update_screen()
            if Utils.find("commission/button_confirm"):
                Logger.log_msg("Found commission info message.")
                Utils.touch_randomly(self.region["combat_com_confirm"])
                continue
            if Utils.find("combat/button_retreat"):
                Utils.script_sleep(3)
                Utils.touch_randomly(self.region["hide_strat_menu"])
                return
            if Utils.find("combat/commander"):
                Utils.touch_randomly(self.region["combat_end_confirm"])
                continue
コード例 #3
0
ファイル: ALAuto.py プロジェクト: wiseasswolfofyoitsu/ALAuto
 def print_cycle_stats(self):
     """Method to print the cycle stats"
     """
     if self.print_stats_check:
         self.stats.print_stats(Utils.check_oil(self.oil_limit))
     self.print_stats_check = False
コード例 #4
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
 def check_movement_threads_func(self, event):
     self.movement_event[event] = (True if (Utils.find(event)) else False)
コード例 #5
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
    def get_fleet_location(self):
        """Method to get the fleet's current location. Note it uses the green
        fleet marker to find the location but returns around the area of the
        feet of the flagship

        Returns:
            array: An array containing the x and y coordinates of the fleet's
            current location.
        """
        coords = [0, 0]
        count = 0

        while coords == [0, 0]:
            Utils.update_screen()
            count += 1

            if count > 4:
                Utils.swipe(960, 540, 960, 540 + 150 + count * 20, 100)
                Utils.update_screen()

            if Utils.find('combat/fleet_ammo', 0.8):
                coords = Utils.find('combat/fleet_ammo', 0.8)
                coords = [coords.x + 140, coords.y + 225 - count * 20]
            elif Utils.find('combat/fleet_arrow', 0.9):
                coords = Utils.find('combat/fleet_arrow', 0.9)
                coords = [coords.x + 25, coords.y + 320 - count * 20]

            if count > 4:
                Utils.swipe(960, 540 + 150 + count * 20, 960, 540, 100)
            elif (math.isclose(coords[0], 160, abs_tol=30)
                  & math.isclose(coords[1], 142, abs_tol=30)):
                coords = [0, 0]

            Utils.update_screen()
        return coords
コード例 #6
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
    def get_enemies(self, blacklist=[], boss=False):
        sim = 0.99
        i = 0
        if blacklist:
            Logger.log_info('Blacklist: ' + str(blacklist))
            self.l = [x for x in self.l if (x not in blacklist)]

        while not self.l:
            if (boss and len(blacklist) > 4) or (
                    not boss and len(blacklist) > 1) or sim < 0.95:
                if i > 3: i = 0
                swipes = {
                    0: lambda: Utils.swipe(960, 240, 960, 940, 300),
                    1: lambda: Utils.swipe(1560, 540, 260, 540, 300),
                    2: lambda: Utils.swipe(960, 940, 960, 240, 300),
                    3: lambda: Utils.swipe(260, 540, 1560, 540, 300)
                }
                swipes.get(i)()
                sim += 0.005
                i += 1
            Utils.update_screen()

            l1 = filter(
                lambda x: x[1] > 160 and x[1] < 938 and x[0] > 180 and x[0] <
                1790,
                map(lambda x: [x[0] - 3, x[1] - 45],
                    Utils.find_all('enemy/fleet_level', sim - 0.15)))
            l1 = [x for x in l1 if (not self.filter_blacklist(x, blacklist))]
            l2 = filter(
                lambda x: x[1] > 160 and x[1] < 938 and x[0] > 180 and x[0] <
                1790,
                map(lambda x: [x[0] + 75, x[1] + 110],
                    Utils.find_all('enemy/fleet_1_down', sim)))
            l2 = [x for x in l2 if (not self.filter_blacklist(x, blacklist))]
            l3 = filter(
                lambda x: x[1] > 160 and x[1] < 938 and x[0] > 180 and x[0] <
                1790,
                map(lambda x: [x[0] + 75, x[1] + 110],
                    Utils.find_all('enemy/fleet_2_down', sim - 0.02)))
            l3 = [x for x in l3 if (not self.filter_blacklist(x, blacklist))]
            l4 = filter(
                lambda x: x[1] > 160 and x[1] < 938 and x[0] > 180 and x[0] <
                1790,
                map(lambda x: [x[0] + 75, x[1] + 130],
                    Utils.find_all('enemy/fleet_3_up', sim - 0.06)))
            l4 = [x for x in l4 if (not self.filter_blacklist(x, blacklist))]
            l5 = filter(
                lambda x: x[1] > 160 and x[1] < 938 and x[0] > 180 and x[0] <
                1790,
                map(lambda x: [x[0] + 75, x[1] + 110],
                    Utils.find_all('enemy/fleet_3_down', sim - 0.06)))
            l5 = [x for x in l5 if (not self.filter_blacklist(x, blacklist))]
            l6 = filter(
                lambda x: x[1] > 160 and x[1] < 938 and x[0] > 180 and x[0] <
                1790,
                map(lambda x: [x[0] + 75, x[1] + 110],
                    Utils.find_all('enemy/fleet_2_up', sim - 0.06)))
            l6 = [x for x in l6 if (not self.filter_blacklist(x, blacklist))]

            self.l = l1 + l2 + l3 + l4 + l5 + l6
            sim -= 0.005

        self.l = Utils.filter_similar_coords(self.l)
        return self.l
コード例 #7
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
    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
コード例 #8
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
    def reach_map(self):
        """
        Method to move to the world where the specified map is located.
        Only works with worlds added to assets (from 1 to 8) and some event maps.
        Also checks if hard mode is enabled.
        """
        _map = 0

        if not self.chapter_map[0].isdigit():
            letter = self.chapter_map[2:3]
            event_maps = ['A', 'B', 'S', 'C', 'D']

            Utils.touch_randomly(self.region['event_button'])
            Utils.wait_update_screen(1)

            if event_maps.index(letter) < 3 and Utils.find("menu/button_normal_mode", 0.8) or \
               event_maps.index(letter) > 2 and not Utils.find("menu/button_normal_mode", 0.8):
                Utils.touch_randomly(self.region['normal_mode_button'])
                Utils.wait_update_screen(1)
        else:
            for x in range(1, 14):
                if Utils.find("maps/map_{}-1".format(x), 0.99):
                    _map = x
                    break

            if _map != 0:
                taps = int(self.chapter_map.split("-")[0]) - _map
                for x in range(0, abs(taps)):
                    if taps >= 1:
                        Utils.touch_randomly(self.region['map_nav_right'])
                        Logger.log_debug("Swiping to the right")
                        Utils.wait_update_screen()
                    else:
                        Utils.touch_randomly(self.region['map_nav_left'])
                        Logger.log_debug("Swiping to the left")
                        Utils.wait_update_screen()

        if Utils.find('maps/map_{}'.format(self.chapter_map), 0.99):
            Logger.log_msg(
                "Successfully reached the world where map is located.")
        else:
            Logger.log_error(
                "Cannot find the specified map, please move to the world where it's located."
            )
            while not Utils.find('maps/map_{}'.format(self.chapter_map), 0.99):
                Utils.wait_update_screen(1)
コード例 #9
0
ファイル: enhancement.py プロジェクト: sandbagimon/ALAuto
    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
コード例 #10
0
ファイル: enhancement.py プロジェクト: sandbagimon/ALAuto
    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(Region(297, 1015, 155, 40))
                    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(Region(54, 57, 67, 67))
                    return
                if Utils.find("menu/dock"):
                    Utils.touch_randomly(self.region['button_favorite'])
                    continue
コード例 #11
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)
コード例 #12
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 (bool): Forces retirement to start even if need_to_retire returns False.

        Returns:
            retirement_done (bool): whether at least one retirement was completed.
        """
        if self.need_to_retire or forced:
            self.last_retire = self.stats.combat_done
            self.called_from_menu = False
            self.retirement_done = False
            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(self.region['combat_sort_button'])
                    Utils.script_sleep(1)
                    continue
                # In case function is called from menu
                if Utils.find("menu/button_battle"):
                    self.called_from_menu = True
                    Utils.touch_randomly(self.region['build_menu'])
                    Utils.script_sleep(1)
                    continue
                if Utils.find("menu/build"):
                    if Utils.find("event/build_limited"):
                        Utils.touch_randomly(self.region['retire_tab_2'])
                    else:
                        Utils.touch_randomly(self.region['retire_tab_1'])
                    Utils.script_sleep(1)
                    continue
                if Utils.find("retirement/selected_none"):
                    self.set_sort()
                    self.retire_ships()
                    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['menu_nav_back'])
                    return self.retirement_done

            Utils.update_screen()
コード例 #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
コード例 #14
0
    def select_ships(self):
        Logger.log_msg("Selecting ships for retirement.")

        for i in range(0, 7):
            Utils.touch_randomly(self.region['select_ship_{}'.format(i)])
コード例 #15
0
ファイル: combat.py プロジェクト: sukitpr/azurlane-auto
    def combat_logic_wrapper(self):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of sortieing combat fleets and resolving combat.

        Returns:
            bool: True if the combat cycle was complete
        """
        if self.check_need_to_sortie():
            Logger.log_msg('Navigating to map.')
            Utils.touch_randomly(self.region['home_menu_attack'])
            Utils.script_sleep(1)
            if not self.resume_previous_sortie:
                self.kills_needed = self.config.combat['kills_needed']
                if self.event_map:
                    Utils.touch_randomly(self.region['event_map'])
                if self.hard_mode:
                    Utils.find_and_touch('map_menu_hard')
                Utils.wait_and_touch('map_{}'.format(self.sortie_map), 5, 0.85)
                Utils.script_sleep()
                Utils.touch_randomly(self.region['map_go_1'])
                Utils.script_sleep()
                Utils.touch_randomly(self.region['map_go_2'])
                Utils.script_sleep(5)
                if self.config.combat['alt_clear_fleet']:
                    Logger.log_msg('Alternate clearing fleet enabled, ' +
                                   'switching to 2nd fleet to clear trash')
                    self.switch_fleet()
                    self.need_to_refocus = False
            # Trash
            if self.clear_trash():
                # Boss
                if self.config.combat['boss_fleet']:
                    Logger.log_msg('Switching to 2nd fleet to kill boss')
                    self.switch_fleet()
                self.clear_boss()
                self.stats.increment_combat_done()
                self.next_combat_time = datetime.now()
                Logger.log_success('Sortie complete. Navigating back home.')
                while not (Utils.exists('home_menu_build')):
                    Utils.touch_randomly(self.region['nav_back'])
                self.set_next_combat_time({'seconds': 10})
            return True
        return False
コード例 #16
0
ファイル: research.py プロジェクト: sukitpr/ALAuto
 def research_cycle(self):
     Utils.wait_update_screen(1)
     if not self.config.research['8Hours'] and Utils.find(
             "research/8h", 0.99):
         return False
     if not self.config.research['6Hours'] and Utils.find(
             "research/6h", 0.99):
         return False
     if not self.config.research['5Hours'] and Utils.find(
             "research/5h", 0.99):
         return False
     if not self.config.research['4Hours'] and Utils.find(
             "research/4h", 0.99):
         return False
     if not self.config.research['2Hours30Minutes'] and Utils.find(
             "research/2_30h", 0.99):
         return False
     if not self.config.research['2Hours'] and Utils.find(
             "research/2h", 0.99):
         return False
     if not self.config.research['1Hour30Minutes'] and Utils.find(
             "research/1_30h", 0.99):
         return False
     if not self.config.research['1Hour'] and Utils.find(
             "research/1h", 0.99):
         return False
     if not self.config.research['30Minutes'] and Utils.find(
             "research/30m", 0.99):
         return False
     if self.config.research['WithoutRequirements'] and not Utils.find(
             "research/nothing", 0.99):
         return False
     if not self.config.research['AllowConsumingCoins'] and Utils.find(
             "research/coins", 0.99):
         return False
     if not self.config.research['AllowConsumingCubes'] and Utils.find(
             "research/cubes", 0.99):
         return False
     if self.config.research[
             'AwardMustContainPRBlueprint'] and not Utils.find(
                 "research/PRBlueprint"):
         return False
     if not self.config.research['AllowFreeProjects'] and Utils.find(
             "research/free", 0.99):
         return False
     if not self.config.research['12Hours'] and Utils.find(
             "research/12h", 0.99):
         return False
     else:
         return True
コード例 #17
0
ファイル: enhancement.py プロジェクト: sandbagimon/ALAuto
    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
コード例 #18
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
    def battle_handler(self, boss=False):
        Logger.log_msg("Starting combat.")

        while not (Utils.find("combat/menu_loading", 0.8)):
            Utils.update_screen()

            if Utils.find("combat/alert_morale_low") or Utils.find(
                    "menu/button_sort"):
                self.retreat_handler()
                return False
            elif Utils.find("combat/combat_pause", 0.7):
                Logger.log_warning(
                    "Loading screen was not found but combat pause is present, assuming combat is initiated normally."
                )
                break
            else:
                Utils.touch_randomly(self.region["menu_combat_start"])
                Utils.script_sleep(1)

        Utils.script_sleep(4)

        while True:
            Utils.update_screen()

            if Utils.find("combat/alert_lock"):
                Logger.log_msg("Locking received ship.")
                Utils.touch_randomly(self.region['lock_ship_button'])
                continue
            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("menu/drop_ssr"):
                Logger.log_msg("Received SSR ship as drop.")
                Utils.touch_randomly(self.region['dismiss_ship_drop'])
                Utils.script_sleep(1)
                continue
            if Utils.find("menu/drop_elite"):
                Logger.log_msg("Received ELITE ship as drop.")
                Utils.touch_randomly(self.region['dismiss_ship_drop'])
                Utils.script_sleep(1)
                continue
            if Utils.find("menu/drop_rare"):
                Logger.log_msg("Received new RARE ship as drop.")
                Utils.touch_randomly(self.region['dismiss_ship_drop'])
                Utils.script_sleep(1)
                continue
            if Utils.find("menu/drop_common"):
                Logger.log_msg("Received new COMMON ship as drop.")
                Utils.touch_randomly(self.region['dismiss_ship_drop'])
                Utils.script_sleep(1)
                continue
            if Utils.find("combat/button_confirm"):
                Logger.log_msg("Combat ended.")
                Utils.touch_randomly(self.region["combat_end_confirm"])
                Utils.script_sleep(1)
                if boss:
                    return True
                Utils.update_screen()
            if Utils.find("combat/alert_unable_battle"):
                Utils.touch_randomly(self.region['close_info_dialog'])
                Utils.script_sleep(3)
                self.exit = 4
                return
            if Utils.find("menu/button_confirm"):
                Logger.log_msg("Found commission info message.")
                Utils.touch_randomly(self.region["combat_com_confirm"])
                continue
            if Utils.find("combat/button_retreat"):
                Utils.script_sleep(3)
                self.combats_done += 1
                #Utils.touch_randomly(self.region["hide_strat_menu"])
                return
            if Utils.find("combat/commander"):
                # prevents fleet with submarines from getting stuck at combat end screen
                Utils.touch_randomly(
                    self.region["combat_dismiss_surface_fleet_summary"])
                continue
コード例 #19
0
                            r"(?P<finished_time>\w+?\s+?\w+?\s+?\d{1,2}\s+?\d{2}:\d{2}:\d{2}\s+?\w+?\s+?\d{4}).*"
                        ))).add_intermediate_result_parser(
                            duration_event_creator),
                Utils.get_output_topic(configuration, "reingest"))
        })


def duration_update(started_script, finished_script, finished_time, timestamp):
    """
    if started script equals finished script duration is calculated
    :param started_script
    :param finished_script
    :param finished_time
    :param timestamp
    :return: duration
    ":exception: ParsingException
    """
    if started_script == finished_script:
        return abs(finished_time - timestamp).seconds
    else:
        raise ParsingException(
            "Message contains different started and finished scripts")


if __name__ == "__main__":
    configuration = Utils.load_config(sys.argv[:])
    KafkaPipeline(
        configuration,
        LogParsingProcessor(configuration,
                            create_event_creators(configuration))).start()
コード例 #20
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
    def clear_map(self):
        """ Clears map.
        """
        Logger.log_msg("Started map clear.")
        Utils.script_sleep(2.5)

        while Utils.find("combat/fleet_lock", 0.99):
            Utils.touch_randomly(self.region["fleet_lock"])
            Logger.log_warning("Fleet lock is not supported, disabling it.")
            Utils.wait_update_screen()

        #swipe map to fit everything on screen
        swipes = {
            'E-C3': lambda: Utils.swipe(960, 800, 960, 400, 100),
            'E-A3': lambda: Utils.swipe(960, 800, 960, 400, 100),
            'E-SP5': lambda: Utils.swipe(350, 500, 960, 800, 100),
            '12-2': lambda: Utils.swipe(1000, 570, 1300, 540, 100),
            '12-3': lambda: Utils.swipe(1250, 530, 1300, 540, 100),
            '12-4': lambda: Utils.swipe(960, 300, 960, 540, 100),
            '13-1': lambda: Utils.swipe(1020, 500, 1300, 540, 100),
            '13-2': lambda: Utils.swipe(1125, 550, 1300, 540, 100),
            '13-3': lambda: Utils.swipe(1150, 510, 1300, 540, 100),
            '13-4': lambda: Utils.swipe(1200, 450, 1300, 540, 100)
        }
        swipes.get(self.chapter_map,
                   lambda: 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"):
                Utils.touch_randomly(self.region['close_info_dialog'])
                self.exit = 4
            if self.config.combat[
                    'retreat_after'] != 0 and self.combats_done >= self.config.combat[
                        'retreat_after']:
                Logger.log_msg("Retreating after defeating {} enemies".format(
                    self.config.combat['retreat_after']))
                self.exit = 5
            if self.exit != 0:
                self.retreat_handler()
                return True
            if Utils.find_in_scaling_range("enemy/fleet_boss"):
                Logger.log_msg("Boss fleet was found.")

                if self.config.combat['boss_fleet']:
                    s = 0
                    swipes = {
                        0: lambda: Utils.swipe(960, 240, 960, 940, 300),
                        1: lambda: Utils.swipe(1560, 540, 260, 540, 300),
                        2: lambda: Utils.swipe(960, 940, 960, 240, 300),
                        3: lambda: Utils.swipe(260, 540, 1560, 540, 300)
                    }

                    Utils.touch_randomly(self.region['button_switch_fleet'])
                    Utils.wait_update_screen(2)
                    boss_region = Utils.find_in_scaling_range(
                        "enemy/fleet_boss")

                    while not boss_region:
                        if s > 3: s = 0
                        swipes.get(s)()

                        Utils.wait_update_screen(0.5)
                        boss_region = Utils.find_in_scaling_range(
                            "enemy/fleet_boss")
                        s += 1
                    Utils.swipe(boss_region.x, boss_region.y, 960, 540, 300)
                    Utils.wait_update_screen()

                boss_region = Utils.find_in_scaling_range("enemy/fleet_boss")
                #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)
                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
コード例 #21
0
def create_event_creators(configuration):
    """
    Tree of different parsers for all types of logs for THINK ANALYTICS
    :param configuration: YML config
    :return: Tree of event_creators
    """
    timezone_name = configuration.property("timezone.name")
    timezones_priority = configuration.property("timezone.priority", "idc")

    duration_event_creator = MutateEventCreator(None, [
        FieldsMapping([
            "started_script", "finished_script", "finished_time", "@timestamp"
        ], "duration", duration_update)
    ])

    concat_httpaccess_timestamp_event_creator = MutateEventCreator(
        Metadata([
            ConfigurableTimestampField("timestamp",
                                       "%d/%b/%Y:%H:%M:%S",
                                       timezone_name,
                                       timezones_priority,
                                       "@timestamp",
                                       include_timezone=True)
        ]), [
            FieldsMapping(["date", "time"],
                          "timestamp",
                          agg_func=lambda x, y: (x + " " + y)[1:-1],
                          remove_intermediate_fields=True)
        ])

    concat_central_timestamp_event_creator = MutateEventCreator(
        Metadata([
            ConfigurableTimestampField("timestamp", "%a %d/%m/%y %H:%M:%S",
                                       timezone_name, timezones_priority,
                                       "@timestamp")
        ]), [
            FieldsMapping(
                ["date", "time"], "timestamp", remove_intermediate_fields=True)
        ])

    traxis_profile_id_event_creator = MutateEventCreator(fields_mappings=[
        FieldsMapping(["subscriberId"], "traxis-profile-id", lambda x: x, True)
    ])

    content_item_id_event_creator = MutateEventCreator(fields_mappings=[
        FieldsMapping(["contentItemId"], "crid",
                      lambda x: "crid{}".format(x.split('crid')[-1]), False)
    ])

    int_request_id_event_creator = MutateEventCreator(fields_mappings=[
        FieldsMapping(["intRequestId"], "request-id", lambda x: x, True)
    ])

    return MatchField(
        "source", {
            "localhost_access_log":
            SourceConfiguration(
                CompositeEventCreator().add_source_parser(
                    EventCreator(
                        Metadata([
                            StringField("date"),
                            StringField("time"),
                            StringField("ip"),
                            StringField("thread"),
                            StringField("http_method"),
                            StringField("url"),
                            StringField("http_version"),
                            StringField("response_code"),
                            StringField("response_time")
                        ]), SplitterParser(
                            delimiter=" ",
                            is_trim=True))).add_intermediate_result_parser(
                                concat_httpaccess_timestamp_event_creator
                            ).add_intermediate_result_parser(
                                EventWithUrlCreator(delete_source_field=True,
                                                    keys_to_underscore=False)).
                add_intermediate_result_parser(traxis_profile_id_event_creator)
                .add_intermediate_result_parser(content_item_id_event_creator).
                add_intermediate_result_parser(int_request_id_event_creator),
                Utils.get_output_topic(configuration, "httpaccess")),
            "RE_SystemOut.log":
            SourceConfiguration(
                EventCreator(
                    Metadata([
                        ConfigurableTimestampField("@timestamp",
                                                   "%d/%m/%y %H:%M:%S.%f",
                                                   timezone_name,
                                                   timezones_priority,
                                                   dayfirst=True,
                                                   use_smart_parsing=True),
                        StringField("level"),
                        StringField("script"),
                        StringField("message")
                    ]),
                    RegexpParser(
                        r"^\[(?P<timestamp>\d{2}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}\.\d{3}\s\D+?)\] "
                        r"(?P<level>\w+?)\s+?-\s+?(?P<script>\S+?)\s+?:\s+?(?P<message>.*)"
                    )), Utils.get_output_topic(configuration, "resystemout")),
            "REMON_SystemOut.log":
            SourceConfiguration(
                EventCreator(
                    Metadata([
                        ConfigurableTimestampField("@timestamp",
                                                   None,
                                                   timezone_name,
                                                   timezones_priority,
                                                   dayfirst=True,
                                                   use_smart_parsing=True),
                        StringField("level"),
                        StringField("script"),
                        StringField("type"),
                        StringField("message")
                    ]),
                    RegexpParser(
                        r"^\[(?P<timestamp>\d{2}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}.\d{3}\s\D+?)\] "
                        r"(?P<level>\w+?)\s+?-\s+?(?P<script>\S+?)\s+?:\s+?\[(?P<type>\S+?)\]\s+?-\s+?(?P<message>.*)"
                    )), Utils.get_output_topic(configuration,
                                               "remonsystemout")),
            "Central.log":
            SourceConfiguration(
                CompositeEventCreator().add_source_parser(
                    EventCreator(
                        Metadata([
                            StringField("date"),
                            StringField("time"),
                            StringField("level"),
                            StringField("message"),
                            StringField("thread"),
                            StringField("c0"),
                            StringField("c1"),
                            StringField("c2"),
                            StringField("role")
                        ]), CsvParser(
                            ",", '"'))).add_intermediate_result_parser(
                                concat_central_timestamp_event_creator),
                Utils.get_output_topic(configuration, "central")),
            "thinkenterprise.log":
            SourceConfiguration(
                EventCreator(
                    Metadata([
                        ConfigurableTimestampField(
                            "@timestamp", "%Y-%m-%d %H:%M:%S,%f",
                            timezone_name, timezones_priority),
                        StringField("level"),
                        StringField("message")
                    ]),
                    RegexpParser(
                        r"^(?P<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})"
                        r":\s+?(?P<level>\w+?)\s+?-\s+?(?P<message>.*)")),
                Utils.get_output_topic(configuration, "thinkenterprise")),
            "gcollector.log":
            SourceConfiguration(
                EventCreator(
                    Metadata([
                        ConfigurableTimestampField("@timestamp",
                                                   "%Y-%m-%dT%H:%M:%S.%f",
                                                   timezone_name,
                                                   timezones_priority,
                                                   include_timezone=True),
                        StringField("process_uptime"),
                        StringField("message")
                    ]),
                    RegexpParser(
                        r"^(?P<timestamp>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}.\d{4})"
                        r":\s+?(?P<process_uptime>\d+?\.\d{3}):\s+?(?P<message>.*)"
                    )), Utils.get_output_topic(configuration, "gcollector")),
            "server.log":
            SourceConfiguration(
                EventCreator(
                    Metadata([
                        ConfigurableTimestampField(
                            "@timestamp", "%Y-%m-%d %H:%M:%S,%f",
                            timezone_name, timezones_priority),
                        StringField("level"),
                        StringField("class_name"),
                        StringField("thread"),
                        StringField("message")
                    ]),
                    RegexpParser(
                        r"^(?P<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})\s+?"
                        r"(?P<level>\w+?)\s+?\[(?P<class_name>.+?)\]\s+?\((?P<thread>.+?)\)\s+?(?P<message>.*)"
                    )), Utils.get_output_topic(configuration, "server")),
            "RE_Ingest.log":
            SourceConfiguration(
                CompositeEventCreator().add_source_parser(
                    DictEventCreator(
                        Metadata([
                            StringField("started_script"),
                            ConfigurableTimestampField("timestamp",
                                                       None,
                                                       timezone_name,
                                                       timezones_priority,
                                                       "@timestamp",
                                                       use_smart_parsing=True),
                            StringField("message"),
                            StringField("finished_script"),
                            ConfigurableTimestampField("finished_time",
                                                       None,
                                                       timezone_name,
                                                       timezones_priority,
                                                       use_smart_parsing=True)
                        ]),
                        RegexpMatchesParser(
                            r"Started\s+?(?P<started_script>.*?\.sh)\s+?"
                            r"(?P<timestamp>\w+?\s+?\w+?\s+?\d{1,2}\s+?\d{2}:\d{2}:\d{2}\s+?\w+?\s+?\d{4})"
                            r"(?P<message>(?:.|\s)*)Finished\s+?(?P<finished_script>.*?\.sh)\s+?"
                            r"(?P<finished_time>\w+?\s+?\w+?\s+?\d{1,2}\s+?\d{2}:\d{2}:\d{2}\s+?\w+?\s+?\d{4}).*"
                        ))).add_intermediate_result_parser(
                            duration_event_creator),
                Utils.get_output_topic(configuration, "reingest"))
        })
コード例 #22
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
    def combat_logic_wrapper(self):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of sortieing combat fleets and resolving combat.

        Returns:
            int: 1 if boss was defeated, 2 if morale is too low and 3 if dock is full.
        """
        self.exit = 0
        self.combats_done = 0
        self.l.clear()
        self.blacklist.clear()

        while True:
            Utils.wait_update_screen()

            if Utils.find("menu/button_sort"):
                Utils.touch_randomly(self.region['close_info_dialog'])
                self.exit = 3
            if Utils.find("combat/alert_morale_low"):
                Utils.touch_randomly(self.region['close_info_dialog'])
                self.exit = 2
                break
            if Utils.find("menu/button_confirm"):
                Logger.log_msg("Found commission info message.")
                Utils.touch_randomly(self.region["combat_com_confirm"])
                continue
            if Utils.find("menu/button_battle"):
                Logger.log_debug("Found menu battle button.")
                Utils.touch_randomly(self.region["menu_button_battle"])
                Utils.wait_update_screen(1)
                continue
            if Utils.find("combat/menu_fleet") and (
                    lambda x: x > 414 and x < 584)(
                        Utils.find("combat/menu_fleet").y
                    ) and not self.config.combat['boss_fleet']:
                if not self.chapter_map[0].isdigit(
                ) and string.ascii_uppercase.index(self.chapter_map[
                        2:3]) < 1 or self.chapter_map[0].isdigit():
                    Logger.log_msg(
                        "Removing second fleet from fleet selection.")
                    Utils.touch_randomly(self.region["clear_second_fleet"])
            if Utils.find("combat/menu_select_fleet"):
                Logger.log_debug("Found fleet select go button.")
                Utils.touch_randomly(self.region["fleet_menu_go"])
                Utils.script_sleep(1)
                continue
            if Utils.find("combat/button_go"):
                Logger.log_debug("Found map summary go button.")
                Utils.touch_randomly(self.region["map_summary_go"])
                continue
            if Utils.find("combat/button_retreat"):
                Logger.log_debug(
                    "Found retreat button, starting clear function.")
                if not self.clear_map():
                    self.stats.increment_combat_attempted()
                    break
            if self.exit == 1 or self.exit == 5:
                self.stats.increment_combat_done()
                break
            if self.exit > 1:
                self.stats.increment_combat_attempted()
                break
            if Utils.find("menu/button_normal_mode"
                          ) and self.chapter_map[0].isdigit():
                Logger.log_debug("Disabling hard mode.")
                Utils.touch_randomly(self.region['normal_mode_button'])
                Utils.wait_update_screen(1)
            if Utils.find_and_touch('maps/map_{}'.format(self.chapter_map),
                                    0.99):
                Logger.log_msg("Found specified map.")
                continue
            else:
                self.reach_map()
                continue

        Utils.script_sleep(1)
        Utils.menu_navigate("menu/button_battle")

        return self.exit
コード例 #23
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.wait_update_screen(1)

            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/commander"):
                # prevents fleet with submarines from getting stuck at combat end screen
                Utils.touch_randomly(self.region["combat_dismiss_surface_fleet_summary"])
                Utils.script_sleep(1)
                continue
            if Utils.find("combat/menu_combat_finished"):
                Utils.touch_randomly(self.region['dismiss_combat_finished'])
                Utils.script_sleep(1)
                continue
コード例 #24
0
ファイル: combat.py プロジェクト: Logi-Ca1/ALAuto
    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:
            boss = True if location else False
            fleet_location = self.get_fleet_location()
            mystery_nodes = []

            if location == []:
                location = fleet_location

            enemies = self.get_enemies(blacklist, boss)

            if mystery_node:
                sim = 0.9

                while mystery_nodes == []:
                    Utils.update_screen()

                    l1 = filter(
                        lambda x: x[1] > 80 and x[1] < 938 and x[0] > 180 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))
                    ]

                    mystery_nodes = l1
                    sim -= 0.005

                    if sim < 0.8:
                        break

                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"]
コード例 #25
0
    def event_logic_wrapper(self):
        """Method that fires off the necessary child methods that encapsulates
        the entire action of completing an event
        """
        event = self.config.events['name']
        events = ['Crosswave', 'Royal_Maids']

        if event in events and not self.finished:
            Logger.log_msg("Opening event menu.")

            while not Utils.find("menu/operation"):
                Utils.find_and_touch(f"event/{event}/menu_button")
                Utils.wait_update_screen(1)

            Logger.log_msg("Event levels: " + str(self.levels))

            while ('EX' in self.levels):
                Utils.wait_update_screen(1)
                if Utils.find(f"event/{event}/ex_completed", 0.98):
                    Logger.log_info("No more EX combats to do.")
                    break

                Utils.touch_randomly(self.region[f'{event.lower()}_ex'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg(f"Finished EX {event.replace('_', ' ')} combat.")
            while ('H' in self.levels):
                Utils.wait_update_screen(1)
                if Utils.find(f"event/{event}/hard_completed"):
                    Logger.log_info("No more Hard combats to do.")
                    break

                Utils.touch_randomly(self.region[f'{event.lower()}_hard'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg(f"Finished Hard {event.replace('_', ' ')} combat.")
            while ('N' in self.levels):
                Utils.wait_update_screen(1)
                if Utils.find(f"event/{event}/normal_completed"):
                    Logger.log_info("No more Normal combats to do.")
                    break

                Utils.touch_randomly(self.region[f'{event.lower()}_normal'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg(f"Finished Normal {event.replace('_', ' ')} combat.")
            while ('E' in self.levels):
                Utils.wait_update_screen(1)
                if Utils.find(f"event/{event}/easy_completed"):
                    Logger.log_info("No more Easy combats to do.")
                    break

                Utils.touch_randomly(self.region[f'{event.lower()}_easy'])
                if self.pre_combat_handler():
                    self.combat_handler()
                    Logger.log_msg(f"Finished Easy {event.replace('_', ' ')} combat.")

            Logger.log_msg("Finished all event combats, going back to menu.")

            Utils.menu_navigate("menu/button_battle")
            self.finished = True
            return
コード例 #26
0
ファイル: ALAuto.py プロジェクト: wiseasswolfofyoitsu/ALAuto
if adb.init():
    Logger.log_msg('Successfully connected to the service.')
    output = Adb.exec_out('wm size').decode('utf-8').strip()

    if not re.search('1920x1080|1080x1920', output):
        Logger.log_error("Resolution is not 1920x1080, please change it.")
        sys.exit()

    Utils.assets = config.assets['server']
else:
    Logger.log_error('Unable to connect to the service.')
    sys.exit()

try:
    while True:
        Utils.update_screen()

        # temporal solution to event alerts
        if not Utils.find("menu/button_battle"):
            Utils.touch_randomly(Region(54, 57, 67, 67))
            Utils.script_sleep(1)
            continue
        if Utils.find("commission/alert_completed"):
            script.run_commission_cycle()
            script.print_cycle_stats()
        if Utils.find("mission/alert_completed"):
            script.run_mission_cycle()
        if Utils.find("headquarters/hq_alert"):
            script.run_hq_cycle()
        if script.should_sortie():
            script.run_sortie_cycle()
コード例 #27
0
ファイル: research.py プロジェクト: sukitpr/ALAuto
    def start_project(self):
        Utils.touch_randomly(self.region['commence_tab'])
        Utils.wait_update_screen(1)
        #solution for projects that don't require confirmation.
        if Utils.find("research/terminate", 0.99):
            return True

        if Utils.find("research/confirm", 0.99):
            Utils.touch_randomly(self.region['confirm_tab'])
            Utils.wait_update_screen(1)
            if Utils.find("research/terminate", 0.99):
                return True

            else:
                return False
コード例 #28
0
ファイル: combat.py プロジェクト: KurutsuKaren/ALAuto
    def reach_map(self):
        """
        Method to move to the world where the specified map is located. 
        Only works with worlds added to assets (from 1 to 8).
        Also checks if hard mode is enabled.
        """
        _map = 0

        if not self.chapter_map[0].isdigit():
            Utils.find_and_touch("menu/button_event")
            Utils.wait_update_screen(1)
        else:
            for x in range(1, 9):
                if Utils.find("maps/map_{}-1".format(x), 0.99):
                    _map = x
                    break

            if _map != 0:
                taps = int(self.chapter_map.split("-")[0]) - _map
                for x in range(0, abs(taps)):
                    if taps >= 1:
                        Utils.touch_randomly(Region(1831, 547, 26, 26))
                        Logger.log_debug("Swiping to the right")
                        Utils.wait_update_screen()
                    else:
                        Utils.touch_randomly(Region(65, 547, 26, 26))
                        Logger.log_debug("Swiping to the left")
                        Utils.wait_update_screen()

        if Utils.find('maps/map_{}'.format(self.chapter_map), 0.99):
            Logger.log_msg(
                "Successfully reached the world where map is located.")
        else:
            Logger.log_error(
                "Cannot find the specified map, please move to the world where it's located."
            )
            while not Utils.find('maps/map_{}'.format(self.chapter_map), 0.99):
                Utils.wait_update_screen(1)
コード例 #29
0
ファイル: research.py プロジェクト: sukitpr/ALAuto
 def collecting_research(self):
     Utils.touch_randomly(self.region['project_click'])
     Utils.wait_update_screen(1)
     if Utils.find("research/item_found"):
         Logger.log_msg("Found completed research project.")
         Utils.touch_randomly(self.region['project_click'])
         Utils.script_sleep(1)
         Utils.touch_randomly(self.region['project_click'])
         return True
     else:
         #solution for azur lane bug
         for searching in range(0, 5):
             Utils.touch_randomly(self.region['right_arrow'])
             Utils.wait_update_screen(1)
             if Utils.find("research/item_found"):
                 Logger.log_msg("Found completed research project.")
                 Utils.script_sleep(1.5)
                 Utils.touch_randomly(self.region['project_click'])
                 Utils.script_sleep(1)
                 Utils.touch_randomly(self.region['project_click'])
                 return True
コード例 #30
0
ファイル: combat.py プロジェクト: KurutsuKaren/ALAuto
    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
コード例 #31
0
ファイル: research.py プロジェクト: sukitpr/ALAuto
    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