Beispiel #1
0
    def get_closest_target(self,
                           blacklist=[],
                           location=[],
                           mystery_node=False):
        """Method to get the enemy closest to the specified location. Note
        this will not always be the enemy that is actually closest due to the
        asset used to find enemies and when enemies are obstructed by terrain
        or the second fleet

        Args:
            blacklist(array, optional): Defaults to []. An array of
            coordinates to exclude when searching for the closest enemy

            location(array, optional): Defaults to []. An array of coordinates
            to replace the fleet location.

        Returns:
            array: An array containing the x and y coordinates of the closest
            enemy to the specified location
        """
        while True:
            fleet_location = self.get_fleet_location()
            mystery_nodes = []

            if location == []:
                location = fleet_location

            enemies = self.get_enemies(blacklist)

            if mystery_node:
                sim = 0.9

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

                    l1 = filter(
                        lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180,
                        Utils.find_all('combat/question_mark', sim))
                    l1 = [x for x in l1 if (x not in blacklist)]

                    mystery_nodes = l1
                    sim -= 0.005

                mystery_nodes = Utils.filter_similar_coords(mystery_nodes)

            targets = enemies + mystery_nodes
            closest = targets[Utils.find_closest(targets, location)[1]]

            Logger.log_info('Current location is: {}'.format(fleet_location))
            Logger.log_info('Enemies found at: {}'.format(targets))
            Logger.log_info('Closest enemy is at {}'.format(closest))

            if closest in self.l:
                x = self.l.index(closest)
                del self.l[x]

            if mystery_node and closest in mystery_nodes:
                return [closest[0], closest[1], "mystery_node"]
            else:
                return [closest[0], closest[1], "enemy"]
Beispiel #2
0
    def get_closest_enemy(self, blacklist=[]):
        """Method to get the enemy closest to the fleet's current 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

        Returns:
            array: An array containing the x and y coordinates of the closest
            enemy to the fleet's current location
        """
        x_dist = 125
        y_dist = 175
        swipes = [['n', 1.0], ['e', 1.0], ['s', 1.5], ['w', 1.5]]
        closest = None
        while closest is None:
            if self.need_to_refocus:
                self.refocus_fleet()
            current_location = self.get_fleet_location()
            for swipe in swipes:
                enemies = Utils.find_all('combat_enemy_fleet', 0.88)
                if enemies:
                    for coord in blacklist:
                        enemies.remove(coord)
                    Logger.log_msg(
                        'Current location is: {}'.format(current_location))
                    Logger.log_msg('Enemies found at: {}'.format(enemies))
                    closest = enemies[Utils.find_closest(
                        enemies, current_location)[1]]
                    Logger.log_msg('Closest enemy is at {}'.format(closest))
                    return [closest[0], closest[1] - 10]
                else:
                    direction, multiplier = swipe[0], swipe[1]
                    if direction == 'n':
                        current_location[1] = (current_location[1] +
                                               (2 * y_dist * multiplier))
                        Utils.swipe(640, 360 - y_dist * multiplier, 640,
                                    360 + y_dist * multiplier, 250)
                    elif direction == 's':
                        current_location[1] = (current_location[1] -
                                               (2 * y_dist * multiplier))
                        Utils.swipe(640, 360 + y_dist * multiplier, 640,
                                    360 - y_dist * multiplier, 250)
                    elif direction == 'e':
                        current_location[0] = (current_location[0] +
                                               (2 * x_dist * multiplier))
                        Utils.swipe(640 + x_dist * multiplier, 360,
                                    640 - x_dist * multiplier, 360, 250)
                    elif direction == 'w':
                        current_location[0] = (current_location[0] -
                                               (2 * x_dist * multiplier))
                        Utils.swipe(640 - x_dist * multiplier, 360,
                                    640 + x_dist * multiplier, 360, 250)
                self.need_to_refocus = True
            x_dist *= 1.5
            y_dist *= 1.5
        return None
Beispiel #3
0
    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
        """
        boss = True if location else False
        fleet_location = self.get_fleet_location()

        if location == []:
            location = fleet_location

        if mystery_node and self.chapter_map[0].isdigit():
            mystery_nodes = self.get_mystery_nodes(blacklist, boss)
            if self.config.combat['focus_on_mystery_nodes'] and len(
                    mystery_nodes) > 0:
                # giving mystery nodes top priority and ignoring enemies
                targets = mystery_nodes
                Logger.log_info("Prioritizing mystery nodes.")
            else:
                # mystery nodes are valid targets, same as enemies
                enemies = self.get_enemies(blacklist, boss)
                targets = enemies + mystery_nodes
        else:
            # target only enemy mobs
            targets = self.get_enemies(blacklist, boss)

        closest = targets[Utils.find_closest(targets, location)[1]]

        Logger.log_info('Current location is: {}'.format(fleet_location))
        Logger.log_info('Targets found at: {}'.format(targets))
        Logger.log_info('Closest target is at {}'.format(closest))

        if closest in self.enemies_list:
            x = self.enemies_list.index(closest)
            del self.enemies_list[x]
            target_type = "enemy"
        else:
            x = self.mystery_nodes_list.index(closest)
            del self.mystery_nodes_list[x]
            target_type = "mystery_node"

        return [closest[0], closest[1], target_type]
Beispiel #4
0
 def clear_boss(self):
     """Finds the boss and battles it
     """
     while not Utils.exists('combat_battle_start'):
         boss = None
         similarity = 0.8
         while boss is None:
             boss = Utils.scroll_find('combat_enemy_boss_alt', 250, 175,
                                      similarity)
             similarity -= 0.015
         Logger.log_msg('Boss found at: {}'.format([boss.x, boss.y]))
         Logger.log_msg('Focusing on boss')
         Utils.swipe(boss.x, boss.y, 640, 360, 250)
         boss = None
         while boss is None:
             boss = Utils.find('combat_enemy_boss_alt', similarity)
             similarity -= 0.015
         # Click slightly above boss to be able to click on it in case
         # the boss is obstructed by another fleet or enemy
         boss_coords = [boss.x + 50, boss.y - 15]
         Utils.touch(boss_coords)
         if Utils.wait_for_exist('combat_unable', 3):
             boss = Utils.scroll_find('combat_enemy_boss_alt', 250, 175,
                                      0.75)
             enemies = Utils.find_all('combat_enemy_fleet', 0.89)
             enemies.remove(boss)
             closest_to_boss = enemies[Utils.find_closest(enemies, boss)[1]]
             Utils.find_and_touch(closest_to_boss)
             if Utils.wait_for_exist('combat_unable', 3):
                 Utils.find_and_touch(self.get_closest_enemy())
                 if Utils.wait_for_exist('combat_battle_start', 3):
                     self.conduct_battle()
         else:
             Utils.script_sleep(5)
             if Utils.find_and_touch('combat_evade'):
                 if Utils.wait_for_exist('combat_battle_start', 3):
                     self.conduct_battle()
                     self.refocus_fleet()
             elif Utils.find_and_touch('combat_items_received'):
                 pass
     if self.conduct_prebattle_check():
         self.conduct_battle()