Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utility changes #70

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions rustplus/utils/rust_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,25 @@ def convert_monument(name: str, override_images: dict) -> Image.Image:
return icon


def convert_event_type_to_name(type) -> str:
if type == 1:
return "Player"
elif type == 2:
return "Explosion"
elif type == 3:
return "Vending Machine"
elif type == 4:
return "CH47 Chinook"
elif type == 5:
return "Cargo Ship"
elif type == 6:
return "Locked Crate"
elif type == 7:
return "Generic Radius"
elif type == 8:
return "Patrol Helicopter"


def entity_type_to_string(id) -> str:
if id == 1:
return "Switch"
Expand Down Expand Up @@ -223,11 +242,21 @@ def __str__(self):
return self.__repr__()


def convert_xy_to_grid(
coords: tuple, map_size: float, catch_out_of_bounds: bool = True
) -> HackyBackwardsCompatCoordClass:
corrected_map_size = _get_corrected_map_size(map_size)
def convert_xy_to_grid(coords: tuple, map_size: float, catch_out_of_bounds: bool = True) -> HackyBackwardsCompatCoordClass:
if _is_outside_grid_system(coords[0], coords[1], map_size):
direction = ""
if coords[1] < 0:
direction += "South"
elif coords[1] > map_size:
direction += "North"
if coords[0] < 0:
direction += "West"
elif coords[0] > map_size:
direction += "East"

return direction if direction else "Out of bounds"

corrected_map_size = _get_corrected_map_size(map_size)
grid_pos_letters = _get_grid_x(coords[0])
grid_pos_number = str(int(_get_grid_y(coords[1], corrected_map_size)))

Expand Down
Loading