rpg_map package
Module contents
- class rpg_map.Map
Bases:
objectA class representing a map.
- Parameters:
bytes (List[int]) – The bytes of the image.
width (int) – The width of the image.
height (int) – The height of the image.
grid_size (int) – The size of a single box in the grid defining how many map revealing points the map has. To see the grid visually, use the with_grid method.
map_type (MapType) – The type of the map. Can be Hidden, Limited or Full.
unlocked (List[Tuple[int, int]]) – The points that are unlocked on the map.
special_points (List[Tuple[int, int]]) – The special points on the map. Used to draw the path.
obstacles (List[List[List[Tuple[int, int]]]]) – The obstacles on the map. Used to draw the path.
background (Optional[List[int]])
- width
The width of the map.
- Type:
int
- height
The height of the map.
- Type:
int
- unlocked
The points that are unlocked on the map.
- Type:
List[Tuple[int, int]]
- clear_extras()
Clears all internal variables that may be set to true to start with a clean slate
- static draw_background(bytes, background)
Draws the background image at every transparent pixel if the background is set
- Parameters:
bytes (List[int]) – The bytes of the image.
background (Optional[List[int]]) – The bytes of the background of the image.
- draw_path(travel, percentage, line_width, path_type=Ellipsis, display_style=Ellipsis, progress_display_type=Ellipsis)
Draws the path from
Travel.computed_path()on the image.- Parameters:
travel (Travel) – The travel object containing the path to draw.
percentage (float) – The percentage of the path to draw. 0.0 to 1.0.
line_width (int) – The width of the line to draw in pixels. Note that if the line has an outline the width will be this +2px
path_type (PathStyle) – The type of path to draw. Can be Solid, Dotted, SolidWithOutline or DottedWithOutline.
path_display (PathDisplayType) – The type of path display to use. Can be BelowMask or AboveMask.
- Returns:
The bytes of the image with the path drawn.
- Return type:
List[int]
- full_image()
Returns the full image. If specified, draws the grid, obstacles, and dots.
- Returns:
The bytes of the image with the grid, obstacles, and dots drawn.
- Return type:
List[int]
- get_bits()
The main method to get the image bytes. Respects the map type and draws the grid, obstacles, and dots if specified.
- Returns:
The bytes of the image with the grid, obstacles, and dots drawn.
- Return type:
List[int]
- height
- masked_image()
Returns the masked image. If specified, draws the grid, obstacles, and dots.
- Returns:
The bytes of the image with the grid, obstacles, and dots drawn.
- Return type:
List[int]
- unlock_point_from_coordinates(x, y)
Takes in a coordinate, if it is close to an “unlocked” grid point it will unlock it and return true, if the point is already unlocked it will return false
- Parameters:
x (int) – The x coordinate of the point to unlock.
y (int) – The y coordinate of the point to unlock.
- Returns:
True if the point was unlocked, False otherwise (already unlocked).
- Return type:
bool
- unlocked
- width
- with_dot(x, y, color, radius)
Adds a dot do be drawn on the map when
Map.full_image(),Map.masked_image()orMap.get_bits()is called- Parameters:
x (int) – The x coordinate of the dot.
y (int) – The y coordinate of the dot.
color (Tuple[int, int, int, int]) – The color of the dot.
radius (int) – The radius of the dot.
- Returns:
The map with the dot.
- Return type:
- with_grid()
If called, a grid is drawn on the map when
Map.full_image(),Map.masked_image()orMap.get_bits()is called
- with_obstacles()
If called, the obstacles are drawn on the map when
Map.full_image(),Map.masked_image()orMap.get_bits()is called
- class rpg_map.MapType
Bases:
objectThe reveal type of the map.
- Hidden
The map reveals only the last entry in the unlocked points.
- Limited
The map reveals all the unlocked points.
- Full
The map reveals all the points.
- Full = MapType.Full
- Hidden = MapType.Hidden
- Limited = MapType.Limited
- class rpg_map.PathDisplayType
Bases:
objectThe way of how to display the path.
- BelowMask
The path is always drawn below the mask.
- AboveMask
The path is always drawn above the mask.
- AboveMask = PathDisplayType.AboveMask
- BelowMask = PathDisplayType.BelowMask
- class rpg_map.PathProgressDisplayType
Bases:
objectThe type of how to display path progress.
- Remaining
The path is drawn from the current position to the destination.
- Travelled
The path is drawn from the start to the current position.
- Progress
The path is drawn from the start to the destination. The path already travelled is converted to greyscale.
- Progress = PathProgressDisplayType.Progress
- Remaining = PathProgressDisplayType.Remaining
- Travelled = PathProgressDisplayType.Travelled
- class rpg_map.PathStyle
Bases:
objectThe style of the path.
- Debug
The path is drawn in debug mode, only a 1px line is drawn.
- Solid
The path is drawn as a solid line.
- Dotted
The path is drawn as a dotted line.
- SolidWithOutline
The path is drawn as a solid line with an outline.
- DottedWithOutline
The path is drawn as a dotted line with an outline.
- Debug
alias of
PathStyle_Debug
- Dotted
alias of
PathStyle_Dotted
- DottedWithOutline
alias of
PathStyle_DottedWithOutline
- Solid
alias of
PathStyle_Solid
- SolidWithOutline
alias of
PathStyle_SolidWithOutline
- class rpg_map.Travel
Bases:
objectA class representing a travel from one point to another on a map. This class contains the shortest path from point A to point B on the map. It uses the A* algorithm to find the path.
- Parameters:
map (Map) – The map to travel on.
current_location (tuple[int, int]) – The current location of the traveler. Given as a tuple of (x, y) coordinates.
destination (tuple[int, int]) – The destination of the traveler. Given as a tuple of (x, y) coordinates.
- computed_path
The computed path from the current location to the destination.
- Type:
list[PathPoint]
- computed_path
- static dbg_map(map)
Displays the map in a black and white view where white are the obstacles and black are the free spaces. This is to debug if a fault is with the pathfinding algorithm or the map reduction algorithm.
- Parameters:
map (Map) – The map to display the black and white view of.
- Returns:
A list of bytes representing the black and white view of the map.
- Return type:
list[int]