Esempio n. 1
0
 def get_pod(self):
     # open inventory
     self.debug('Opening inventory')
     screen = tools.screen_game(self.game_location)
     self.press_key(data.KeyboardShortcuts['Inventory'])
     # wait for inventory to open
     self.monitor_game_screen(tolerance=2.5, screen=screen)
     # check for pause or suspend
     self.pause_event.wait()
     if self.suspend: return
     # get podbar color & percentage
     location = self.get_box_location('PodBar')
     screen = tools.screen_game(location)
     color, percentage = tools.get_dominant_color(screen)
     # close inventory
     self.debug('Closing inventory')
     screen = tools.screen_game(self.game_location)
     self.press_key(data.KeyboardShortcuts['Inventory'])
     # wait for inventory to close
     self.monitor_game_screen(tolerance=2.5, screen=screen)
     # check for pause or suspend
     self.pause_event.wait()
     if self.suspend: return
     # check if podbar is empty
     if tools.color_matches(color,
                            data.Colors['Empty PodBar'],
                            tolerance=10):
         return 0
     else:
         # update pod bar
         self.set_pod(percentage)
         return percentage
Esempio n. 2
0
    def get_pod(self):
        '''
		Detects the level of pod by looking at the bar below the spells
		'''
        self.pause_event.wait()
        if self.suspend: return
        # get podbar color & percentage
        location = self.get_box_location('PodBar')
        screen = tools.screen_game(location)
        color, percentage = tools.get_dominant_color(screen)
        if tools.color_matches(color,
                               data.Colors['Empty PodBar'],
                               tolerance=10):
            percentage = 100.0 - percentage
        # update pod bar
        self.log(f"Pod {percentage}%, color: {color}")
        self.set_pod(percentage)
        return percentage
Esempio n. 3
0
 def check_location_color(self, location):
     if location['color'] is None:
         return True
     location['color'] = parser.parse_color(location['color'])
     game_x, game_y, game_width, game_height = self.game_location
     coordones = []
     x, y = tools.adjust_click_position(location['x'], location['y'], location['width'], location['height'], \
                game_x, game_y, game_width, game_height)
     kernel = [[-1, -1], [0, -1], [1, -1], [-1, 0], [0, 0], [1, 0], [-1, 1],
               [0, 1], [1, 1]]
     for offset in kernel:
         coordones.append([x + offset[0], y + offset[1]])
     tools.move_mouse(x + 5, y + 5)
     self.sleep(0.05)
     for coord in coordones:
         color = tools.get_pixel_color(coord[0], coord[1])
         if tools.color_matches(color, location['color'], tolerance=10):
             return True
     return False
Esempio n. 4
0
    def check_resource_color(self, resource):
        # check pixel color
        if self.check_resources_color:
            game_x, game_y, game_width, game_height = self.game_location
            x, y = tools.adjust_click_position(resource['x'], resource['y'],
                                               resource['width'],
                                               resource['height'], game_x,
                                               game_y, game_width, game_height)
            color = tools.get_pixel_color(x, y)
            resource['color'] = parser.parse_color(resource['color'])
            if resource['color'] is not None and not tools.color_matches(
                    color, resource['color'], tolerance=10):
                self.debug(
                    "Ignoring non-matching resource {'x': %d, 'y': %d, 'color': %s} on pixel {'x': %d, 'y': %d, 'color': %s}"
                    % (resource['x'], resource['y'], resource['color'], x, y,
                       color))
                # remove current resource from minimap (index = 0)
                self.remove_from_minimap(0)
                return False

        return True