Skip to content

Commit

Permalink
Merge pull request #6 from kywch/patch-1
Browse files Browse the repository at this point in the history
Update global_map.py
  • Loading branch information
thatguy11325 authored Apr 7, 2024
2 parents a11bac9 + 7b23e5f commit 19423f0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pokemonred_puffer/global_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ def local_to_global(r: int, c: int, map_n: int):
map_x,
map_y,
) = MAP_DATA[map_n]["coordinates"]
return r + map_y, c + map_x
gy = r + map_y
gx = c + map_x
if 0 > gy >= GLOBAL_MAP_SHAPE[0] or 0 > gx >= GLOBAL_MAP_SHAPE[1]:
print(f"coord out of bounds! global: ({gx}, {gy}) game: ({r}, {c}, {map_n})")
return 0, 0
return gy, gx
except KeyError:
print(f"Map id {map_n} not found in map_data.json.")
return r + 0, c + 0
except IndexError:
print(f"Coord {map_x}, {map_y} out of bounds for map id {map_n}.")
return 0, 0

0 comments on commit 19423f0

Please sign in to comment.