예제 #1
0
    def get_mystery_nodes(self, blacklist=[], boss=False):
        """Method which returns a list of mystery nodes' coordinates.
        """
        if len(blacklist) > 2:
            self.mystery_nodes_list.clear()
        
        if len(self.mystery_nodes_list) == 0 and not Utils.find('combat/question_mark', 0.9):
            # if list is empty and a question mark is NOT found
            return self.mystery_nodes_list
        else:
            # list has elements or list is empty but a question mark has been found
            filter_coordinates = True if len(self.mystery_nodes_list) == 0 else False
            sim = 0.95

            while not self.mystery_nodes_list and sim > 0.93:
                Utils.update_screen()

                l1 = filter(lambda x:(x[1] > 242 and x[1] < 1070 and x[0] > 180 and x[0] < 955) or (x[1] > 160 and x[1] < 938 and x[0] > 550 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))]

                self.mystery_nodes_list = l1
                sim -= 0.005
        
            if filter_coordinates:
                self.mystery_nodes_list = Utils.filter_similar_coords(self.mystery_nodes_list)
            
            return self.mystery_nodes_list
예제 #2
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"]
예제 #3
0
    def get_enemies(self, blacklist=[], boss=False):
        sim = 0.99
        filter_coordinates = True if len(self.enemies_list) == 0 else False
        if blacklist:
            Logger.log_info('Blacklist: ' + str(blacklist))
            if len(blacklist) > 2:
                self.enemies_list.clear()

        while not self.enemies_list:
            if (boss and len(blacklist) > 4) or (not boss and len(blacklist) > 3) or sim < 0.97:
                if self.swipe_counter > 3: self.swipe_counter = 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(self.swipe_counter)()
                sim += 0.005
                self.swipe_counter += 1
            Utils.update_screen()

            l1 = filter(lambda x:(x[1] > 242 and x[1] < 1070 and x[0] > 180 and x[0] < 955) or (x[1] > 160 and x[1] < 938 and x[0] > 550 and x[0] < 1770), map(lambda x:[x[0] - 3, x[1] - 27], Utils.find_all('enemy/fleet_level', sim - 0.025, useMask=True)))
            l1 = [x for x in l1 if (not self.filter_blacklist(x, blacklist))]
            Logger.log_debug("L1: " +str(l1))
            l2 = filter(lambda x:(x[1] > 242 and x[1] < 1070 and x[0] > 180 and x[0] < 955) or (x[1] > 160 and x[1] < 938 and x[0] > 550 and x[0] < 1770), map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_1_down', sim - 0.02)))
            l2 = [x for x in l2 if (not self.filter_blacklist(x, blacklist))]
            Logger.log_debug("L2: " +str(l2))
            l3 = filter(lambda x:(x[1] > 242 and x[1] < 1070 and x[0] > 180 and x[0] < 955) or (x[1] > 160 and x[1] < 938 and x[0] > 550 and x[0] < 1770), map(lambda x:[x[0] + 75, x[1] + 90], Utils.find_all('enemy/fleet_2_down', sim - 0.02)))
            l3 = [x for x in l3 if (not self.filter_blacklist(x, blacklist))]
            Logger.log_debug("L3: " +str(l3))
            l4 = filter(lambda x:(x[1] > 242 and x[1] < 1070 and x[0] > 180 and x[0] < 955) or (x[1] > 160 and x[1] < 938 and x[0] > 550 and x[0] < 1770), map(lambda x:[x[0] + 75, x[1] + 125], Utils.find_all('enemy/fleet_3_up', sim - 0.035)))
            l4 = [x for x in l4 if (not self.filter_blacklist(x, blacklist))]
            Logger.log_debug("L4: " +str(l4))
            l5 = filter(lambda x:(x[1] > 242 and x[1] < 1070 and x[0] > 180 and x[0] < 955) or (x[1] > 160 and x[1] < 938 and x[0] > 550 and x[0] < 1770), map(lambda x:[x[0] + 75, x[1] + 100], Utils.find_all('enemy/fleet_3_down', sim - 0.035)))
            l5 = [x for x in l5 if (not self.filter_blacklist(x, blacklist))]
            Logger.log_debug("L5: " +str(l5))
            l6 = filter(lambda x:(x[1] > 242 and x[1] < 1070 and x[0] > 180 and x[0] < 955) or (x[1] > 160 and x[1] < 938 and x[0] > 550 and x[0] < 1770), map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_2_up', sim - 0.025)))
            l6 = [x for x in l6 if (not self.filter_blacklist(x, blacklist))]
            Logger.log_debug("L6: " +str(l6))

            if self.config.combat['siren_elites']:
                l7 = Utils.find_siren_elites()
                l7 = [x for x in l7 if (not self.filter_blacklist(x, blacklist))]
                Logger.log_debug("L7: " +str(l7))
                self.enemies_list = l1 + l2 + l3 + l4 + l5 + l6 + l7
            else:
                self.enemies_list = l1 + l2 + l3 + l4 + l5 + l6
			
            sim -= 0.005

        if filter_coordinates:
            self.enemies_list = Utils.filter_similar_coords(self.enemies_list)
        return self.enemies_list
예제 #4
0
    def get_enemies(self, blacklist=[]):
        sim = 0.99
        if blacklist != []:
            Logger.log_info('Blacklist: ' + str(blacklist))
            self.l = [x for x in self.l if (x not in blacklist)]

        while self.l == []:
            Utils.update_screen()

            l1 = filter(
                lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180,
                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 (x not in blacklist)]
            l2 = filter(
                lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180,
                map(lambda x: [x[0] + 75, x[1] + 110],
                    Utils.find_all('enemy/fleet_1_down', sim)))
            l2 = [x for x in l2 if (x not in blacklist)]
            l3 = filter(
                lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180,
                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 (x not in blacklist)]
            l4 = filter(
                lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180,
                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 (x not in blacklist)]
            l5 = filter(
                lambda x: x[1] > 80 and x[1] < 977 and x[0] > 180,
                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 (x not in blacklist)]

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

        self.l = Utils.filter_similar_coords(self.l)
        return self.l
예제 #5
0
    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] < 977 and x[0] > 180, map(lambda x:[x[0] - 3, x[1] - 45], Utils.find_all('enemy/fleet_level', sim - 0.15, self.chapter_map)))
            l1 = [x for x in l1 if (not self.filter_blacklist(x, blacklist))]
            l2 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_1_down', sim, self.chapter_map)))
            l2 = [x for x in l2 if (not self.filter_blacklist(x, blacklist))]
            l3 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_2_down', sim - 0.02, self.chapter_map)))
            l3 = [x for x in l3 if (not self.filter_blacklist(x, blacklist))]
            l4 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 130], Utils.find_all('enemy/fleet_3_up', sim - 0.06, self.chapter_map)))
            l4 = [x for x in l4 if (not self.filter_blacklist(x, blacklist))]
            l5 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_3_down', sim - 0.06, self.chapter_map)))
            l5 = [x for x in l5 if (not self.filter_blacklist(x, blacklist))]
            l6 = filter(lambda x:x[1] > 160 and x[1] < 977 and x[0] > 180, map(lambda x:[x[0] + 75, x[1] + 110], Utils.find_all('enemy/fleet_2_up', sim - 0.06, self.chapter_map)))
            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
예제 #6
0
    def get_mystery_nodes(self, blacklist=[], boss=False):
        """Method which returns a list of mystery nodes' coordinates.
        """
        if len(blacklist) > 2:
            self.mystery_nodes_list.clear()

        if len(self.mystery_nodes_list) == 0 and not Utils.find(
                'combat/question_mark', 0.9):
            # if list is empty and a question mark is NOT found
            return self.mystery_nodes_list
        else:
            # list has elements or list is empty but a question mark has been found
            filter_coordinates = True if len(
                self.mystery_nodes_list) == 0 else False
            sim = 0.95

            while not self.mystery_nodes_list and sim > 0.93:
                Utils.update_screen()

                l1 = list(
                    map(
                        lambda x: [x[0], x[1] + 140],
                        Utils.find_all_with_resize('combat/question_mark',
                                                   sim)))
                # filter coordinates inside prohibited regions
                for p_region in self.prohibited_region.values():
                    l1 = [x for x in l1 if (not p_region.contains(x))]
                l1 = [
                    x for x in l1 if (not self.filter_blacklist(x, blacklist))
                ]

                self.mystery_nodes_list = l1
                sim -= 0.005

            if filter_coordinates:
                self.mystery_nodes_list = Utils.filter_similar_coords(
                    self.mystery_nodes_list)

            return self.mystery_nodes_list
예제 #7
0
    def get_enemies(self, blacklist=[], boss=False):
        sim = 0.99
        filter_coordinates = True if len(self.enemies_list) == 0 else False
        if blacklist:
            Logger.log_info('Blacklist: ' + str(blacklist))
            if len(blacklist) > 2:
                self.enemies_list.clear()

        while not self.enemies_list:
            if (boss and len(blacklist) > 4) or (
                    not boss and len(blacklist) > 3) or sim < 0.985:
                if self.swipe_counter > 3: self.swipe_counter = 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(self.swipe_counter)()
                sim += 0.005
                self.swipe_counter += 1
            Utils.update_screen()

            if self.use_intersection:
                base_region_type = Region(60, 60, 100, 100)
                base_region_level = Region(-60, -80, 100, 100)
                single_triangle = map(
                    lambda coords: Region(
                        coords[0].item() + base_region_type.x, coords[1].item(
                        ) + base_region_type.y, base_region_type.w,
                        base_region_type.h),
                    Utils.find_all('enemy/enemyt1', sim - 0.04, useMask=True))
                double_triangle = map(
                    lambda coords: Region(
                        coords[0].item() + base_region_type.x, coords[1].item(
                        ) + base_region_type.y, base_region_type.w,
                        base_region_type.h),
                    Utils.find_all('enemy/enemyt2', sim - 0.075, useMask=True))
                triple_triangle = map(
                    lambda coords: Region(
                        coords[0].item() + base_region_type.x, coords[1].item(
                        ) + base_region_type.y, base_region_type.w,
                        base_region_type.h),
                    Utils.find_all('enemy/enemyt3', sim - 0.075, useMask=True))
                lv_enemies = list(
                    map(
                        lambda coords: Region(
                            coords[0].item() + base_region_level.x, coords[
                                1].item() + base_region_level.y,
                            base_region_level.w, base_region_level.h),
                        Utils.find_all('enemy/enemylv',
                                       sim - 0.04,
                                       useMask=True)))
                t1_enemies = []
                for st in single_triangle:
                    t1_enemies.extend(map(st.intersection, lv_enemies))
                t1_enemies = filter(None, t1_enemies)
                t2_enemies = []
                for dt in double_triangle:
                    t2_enemies.extend(map(dt.intersection, lv_enemies))
                t2_enemies = filter(None, t2_enemies)
                t3_enemies = []
                for tt in triple_triangle:
                    t3_enemies.extend(map(tt.intersection, lv_enemies))
                t3_enemies = filter(None, t3_enemies)

                intersections = []
                intersections.extend(t1_enemies)
                intersections.extend(t2_enemies)
                intersections.extend(t3_enemies)
                # filter duplicate intersections by intersecting them
                filtered_intersections = []
                while intersections:
                    region = intersections.pop(0)
                    new_intersections = []
                    for item in intersections:
                        res = region.intersection(item)
                        if res:
                            region = res
                        else:
                            new_intersections.append(item)
                    intersections = new_intersections
                    filtered_intersections.append(region)
                enemies_coords = map(Region.get_center, filtered_intersections)
                # filter coordinates inside prohibited regions
                for p_region in self.prohibited_region.values():
                    enemies_coords = [
                        x for x in enemies_coords if (not p_region.contains(x))
                    ]

                self.enemies_list = [
                    x for x in enemies_coords
                    if (not self.filter_blacklist(x, blacklist))
                ]

            else:
                l1 = list(
                    map(
                        lambda x: [x[0] - 3, x[1] - 27],
                        Utils.find_all_with_resize('enemy/fleet_level',
                                                   sim - 0.025,
                                                   useMask=True)))
                Logger.log_debug("L1: " + str(l1))
                l2 = list(
                    map(
                        lambda x: [x[0] + 75, x[1] + 110],
                        Utils.find_all_with_resize('enemy/fleet_1_down',
                                                   sim - 0.02)))
                Logger.log_debug("L2: " + str(l2))
                l3 = list(
                    map(
                        lambda x: [x[0] + 75, x[1] + 90],
                        Utils.find_all_with_resize('enemy/fleet_2_down',
                                                   sim - 0.02)))
                Logger.log_debug("L3: " + str(l3))
                l4 = list(
                    map(
                        lambda x: [x[0] + 75, x[1] + 125],
                        Utils.find_all_with_resize('enemy/fleet_3_up',
                                                   sim - 0.035)))
                Logger.log_debug("L4: " + str(l4))
                l5 = list(
                    map(
                        lambda x: [x[0] + 75, x[1] + 100],
                        Utils.find_all_with_resize('enemy/fleet_3_down',
                                                   sim - 0.035)))
                Logger.log_debug("L5: " + str(l5))
                l6 = list(
                    map(
                        lambda x: [x[0] + 75, x[1] + 110],
                        Utils.find_all_with_resize('enemy/fleet_2_up',
                                                   sim - 0.025)))
                Logger.log_debug("L6: " + str(l6))
                enemies_coords = l1 + l2 + l3 + l4 + l5 + l6
                # filter coordinates inside prohibited regions
                for p_region in self.prohibited_region.values():
                    enemies_coords = [
                        x for x in enemies_coords if (not p_region.contains(x))
                    ]
                self.enemies_list = [
                    x for x in enemies_coords
                    if (not self.filter_blacklist(x, blacklist))
                ]

            if self.config.combat['siren_elites']:
                l7 = Utils.find_siren_elites()
                # filter coordinates inside prohibited regions
                for p_region in self.prohibited_region.values():
                    l7 = [x for x in l7 if (not p_region.contains(x))]
                l7 = [
                    x for x in l7 if (not self.filter_blacklist(x, blacklist))
                ]
                Logger.log_debug("L7 " + str(l7))
                self.enemies_list.extend(l7)

            sim -= 0.005

        if filter_coordinates:
            self.enemies_list = Utils.filter_similar_coords(self.enemies_list,
                                                            distance=67)
        return self.enemies_list