from Options import PlandoConnection from .connections import RANDOMIZED_CONNECTIONS from .portals import REGION_ORDER, SHOP_POINTS, CHECKPOINTS from .transitions import TRANSITIONS REVERSED_RANDOMIZED_CONNECTIONS = {v: k for k, v in RANDOMIZED_CONNECTIONS.items()} def find_spot(portal_key: int) -> str: """finds the spot associated with the portal key""" parent = REGION_ORDER[portal_key // 100] if portal_key % 100 == 0: return f"{parent} Portal" if portal_key % 100 // 10 == 1: return SHOP_POINTS[parent][portal_key % 10] return CHECKPOINTS[parent][portal_key % 10] def reverse_portal_exits_into_portal_plando(portal_exits: list[int]) -> list[PlandoConnection]: return [ PlandoConnection("Autumn Hills", find_spot(portal_exits[0]), "both"), PlandoConnection("Riviere Turquoise", find_spot(portal_exits[1]), "both"), PlandoConnection("Howling Grotto", find_spot(portal_exits[2]), "both"), PlandoConnection("Sunken Shrine", find_spot(portal_exits[3]), "both"), PlandoConnection("Searing Crags", find_spot(portal_exits[4]), "both"), PlandoConnection("Glacial Peak", find_spot(portal_exits[5]), "both"), ] def reverse_transitions_into_plando_connections(transitions: list[list[int]]) -> list[PlandoConnection]: plando_connections = [] for connection in [ PlandoConnection(REVERSED_RANDOMIZED_CONNECTIONS[TRANSITIONS[transition[0]]], TRANSITIONS[transition[1]], "both") for transition in transitions ]: if connection.exit in {con.entrance for con in plando_connections}: continue plando_connections.append(connection) return plando_connections