diff --git a/Dolphin scripts/Entrance Randomizer/lib/constants.py b/Dolphin scripts/Entrance Randomizer/lib/constants.py index 346dce4..0bc5af6 100644 --- a/Dolphin scripts/Entrance Randomizer/lib/constants.py +++ b/Dolphin scripts/Entrance Randomizer/lib/constants.py @@ -28,15 +28,15 @@ print("Seed set to:", seed_string) -@dataclass +@dataclass(frozen=True) class Addresses: version_string: str - prev_area: list[int] + prev_area: tuple[int, ...] current_area: int area_load_state: int - player_x: list[int] - player_y: list[int] - player_z: list[int] + player_x: tuple[int, ...] + player_y: tuple[int, ...] + player_z: tuple[int, ...] item_swap: int shaman_shop_struct: int @@ -44,12 +44,12 @@ class Addresses: TRANSITION_INFOS_DICT = { area.area_id: area for area in chain(*transition_infos) } -ALL_TRANSITION_AREAS = {area.area_id for area in chain(*transition_infos)} -ALL_POSSIBLE_TRANSITIONS = [ +ALL_TRANSITION_AREAS = frozenset(area.area_id for area in chain(*transition_infos)) +ALL_POSSIBLE_TRANSITIONS = tuple( (area.area_id, exit_.area_id) for area in TRANSITION_INFOS_DICT.values() for exit_ in area.exits -] +) _game_id_base = "".join([ @@ -75,45 +75,45 @@ class Addresses: "GPH": { "D": Addresses( version_string="GC DE 0-00", - prev_area=[0x80747648], + prev_area=(0x80747648,), current_area=0x80417F50, area_load_state=TODO, - player_x=[], - player_y=[], - player_z=[], + player_x=(), + player_y=(), + player_z=(), item_swap=0x804C7734, shaman_shop_struct=TODO, ), "E": Addresses( version_string="GC US 0-00", - prev_area=[0x8072B648], + prev_area=(0x8072B648,), current_area=0x8041BEB4, area_load_state=0x8041BEC8, - player_x=[0x8041BE4C, 0x338], - player_y=[0x8041BE4C, 0x33C], - player_z=[0x8041BE4C, 0x340], + player_x=(0x8041BE4C, 0x338), + player_y=(0x8041BE4C, 0x33C), + player_z=(0x8041BE4C, 0x340), item_swap=0x804CB694, shaman_shop_struct=0x7E00955C, ), "F": Addresses( version_string="GC FR 0-00", - prev_area=[0x80747648], + prev_area=(0x80747648,), current_area=0x80417F30, area_load_state=TODO, - player_x=[], - player_y=[], - player_z=[], + player_x=(), + player_y=(), + player_z=(), item_swap=0x804C7714, shaman_shop_struct=TODO, ), "P": Addresses( version_string="GC EU 0-00", - prev_area=[0x80747648], + prev_area=(0x80747648,), current_area=0x80417F10, area_load_state=TODO, - player_x=[], - player_y=[], - player_z=[], + player_x=(), + player_y=(), + player_z=(), item_swap=0x804C76F4, shaman_shop_struct=TODO, ), @@ -121,23 +121,23 @@ class Addresses: "RPF": { "E": Addresses( version_string="Wii US 0-00", - prev_area=[0x804542DC, 0x8], + prev_area=(0x804542DC, 0x8), current_area=0x80448D04, area_load_state=TODO, - player_x=[], - player_y=[], - player_z=[], + player_x=(), + player_y=(), + player_z=(), item_swap=0x80446608, shaman_shop_struct=TODO, ), "P": Addresses( version_string="Wii EU 0-00", - prev_area=[0x804546DC, 0x18], + prev_area=(0x804546DC, 0x18), current_area=0x80449104, area_load_state=TODO, - player_x=[], - player_y=[], - player_z=[], + player_x=(), + player_y=(), + player_z=(), item_swap=0x80446A08, shaman_shop_struct=TODO, ), diff --git a/Dolphin scripts/Entrance Randomizer/lib/transition_infos.py b/Dolphin scripts/Entrance Randomizer/lib/transition_infos.py index b6676ca..e8d27f5 100644 --- a/Dolphin scripts/Entrance Randomizer/lib/transition_infos.py +++ b/Dolphin scripts/Entrance Randomizer/lib/transition_infos.py @@ -37,48 +37,48 @@ class AreaJSON(TypedDict): TransitionInfosJSON = None -@dataclass +@dataclass(frozen=True) class Exit: area_id: int area_name: str requires: None | list[list[str]] -@dataclass +@dataclass(frozen=True) class Area: area_id: int name: str default_entrance: int - exits: list[Exit] + exits: tuple[Exit, ...] class MajorAreas(NamedTuple): - jungle: list[Area] - native_territory: list[Area] - lost_caverns: list[Area] - snowy_mountains: list[Area] + jungle: tuple[Area, ...] + native_territory: tuple[Area, ...] + lost_caverns: tuple[Area, ...] + snowy_mountains: tuple[Area, ...] def major_areas_from_JSON(transition_infos_json: TransitionInfosJSON): # noqa: N802 - major_areas = [ - [ + major_areas = ( + tuple( Area( int(area["area_id"], 16), area["area_name"], int(area["default_entrance"] or "0x0", 16), - [ + tuple( Exit( int(exit_["area_id"] or "0x0", 16), exit_["area_name"], exit_["requires"], ) for exit_ in area["exits"] - ], + ), ) for area in major_area - ] + ) for major_area in transition_infos_json.values() - ] + ) return MajorAreas(*major_areas)