Beispiel #1
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
Beispiel #2
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
Beispiel #3
0
	def add_point(self, point, name=None, color=None, redraw=True):
		# set point coordinates
		new_point = {
			'x': point['x'],
			'y': point['y'],
			'width': point['width'],
			'height': point['height']
		}
		# set point name
		if name is not None:
			new_point['name'] = name
		elif 'name' in point:
			new_point['name'] = point['name']
		else:
			new_point['name'] = None
		# set point color
		new_point['color'] = color
		new_point['origin_color'] = parse_color(point['color'], as_hex=True) if 'color' in point else None
		# add point
		self.points.append(new_point)
		if redraw:
			self.drawing_area.queue_draw()