From 7b23e5f187fc495e83f9ad6178d15d9a18a83c0b Mon Sep 17 00:00:00 2001 From: Kyoung Whan Choe Date: Sat, 6 Apr 2024 20:20:29 -0700 Subject: [PATCH] Update global_map.py --- pokemonred_puffer/global_map.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pokemonred_puffer/global_map.py b/pokemonred_puffer/global_map.py index 7ed6c75..76957ce 100644 --- a/pokemonred_puffer/global_map.py +++ b/pokemonred_puffer/global_map.py @@ -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