Skip to content

Commit

Permalink
cleaner logic on local to global
Browse files Browse the repository at this point in the history
  • Loading branch information
thatguy11325 committed Apr 15, 2024
1 parent 94408fa commit 9335909
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pokemonred_puffer/global_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def local_to_global(r: int, c: int, map_n: int):
) = MAP_DATA[map_n]["coordinates"]
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
if 0 <= gy < GLOBAL_MAP_SHAPE[0] and 0 <= gx < GLOBAL_MAP_SHAPE[1]:
return gy, gx
print(f"coord out of bounds! global: ({gx}, {gy}) game: ({r}, {c}, {map_n})")
return 0, 0
except KeyError:
print(f"Map id {map_n} not found in map_data.json.")
return 0, 0

0 comments on commit 9335909

Please sign in to comment.